- @Override
- protected RemoteOperationResult run(WebdavClient client) {
- RemoteOperationResult result = null;
- MkColMethod mkcol = null;
- try {
- mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
- int status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
- if (mkcol.succeeded()) {
- // Save new directory in local database
- OCFile newDir = new OCFile(mRemotePath);
- newDir.setMimetype("DIR");
- newDir.setParentId(mParentDirId);
- newDir.setModificationTimestamp(System.currentTimeMillis());
- mStorageManager.saveFile(newDir);
+ public void saveFolderInDB() {
+ if (mCreateFullPath && getStorageManager().
+ getFileByPath(FileStorageUtils.getParentPath(mRemotePath)) == null){// When parent
+ // of remote path
+ // is not created
+ String[] subFolders = mRemotePath.split("/");
+ String composedRemotePath = "/";
+
+ // For each antecesor folders create them recursively
+ for (int i=0; i<subFolders.length; i++) {
+ String subFolder = subFolders[i];
+ if (!subFolder.isEmpty()) {
+ composedRemotePath = composedRemotePath + subFolder + "/";
+ mRemotePath = composedRemotePath;
+ saveFolderInDB();
+ }