|
@@ -44,6 +44,7 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
|
import com.owncloud.android.lib.resources.shares.ShareType;
|
|
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
|
|
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
|
|
import com.owncloud.android.lib.resources.status.OCCapability;
|
|
import com.owncloud.android.lib.resources.status.OCCapability;
|
|
|
|
+import com.owncloud.android.operations.RemoteOperationFailedException;
|
|
import com.owncloud.android.utils.FileStorageUtils;
|
|
import com.owncloud.android.utils.FileStorageUtils;
|
|
import com.owncloud.android.utils.MimeType;
|
|
import com.owncloud.android.utils.MimeType;
|
|
import com.owncloud.android.utils.MimeTypeUtil;
|
|
import com.owncloud.android.utils.MimeTypeUtil;
|
|
@@ -250,6 +251,14 @@ public class FileDataStorageManager {
|
|
return overriden;
|
|
return overriden;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * traverses a files parent tree to be able to store a file with its parents.
|
|
|
|
+ * Throws a RemoteOperationFailedException in case the parent can't be retrieved.
|
|
|
|
+ *
|
|
|
|
+ * @param file the file
|
|
|
|
+ * @param context the app context
|
|
|
|
+ * @return the parent file
|
|
|
|
+ */
|
|
public OCFile saveFileWithParent(OCFile file, Context context) {
|
|
public OCFile saveFileWithParent(OCFile file, Context context) {
|
|
if (file.getParentId() == 0 && !file.getRemotePath().equals("/")) {
|
|
if (file.getParentId() == 0 && !file.getRemotePath().equals("/")) {
|
|
String remotePath = file.getRemotePath();
|
|
String remotePath = file.getRemotePath();
|
|
@@ -267,8 +276,15 @@ public class FileDataStorageManager {
|
|
|
|
|
|
returnFile = saveFileWithParent(remoteFolder, context);
|
|
returnFile = saveFileWithParent(remoteFolder, context);
|
|
} else {
|
|
} else {
|
|
- returnFile = null;
|
|
|
|
- Log_OC.e(TAG, "Error during saving file with parents: " + file.getRemotePath());
|
|
|
|
|
|
+ Exception exception = result.getException();
|
|
|
|
+ String message = "Error during saving file with parents: " + file.getRemotePath() + " / "
|
|
|
|
+ + result.getLogMessage();
|
|
|
|
+
|
|
|
|
+ if (exception != null) {
|
|
|
|
+ throw new RemoteOperationFailedException(message, exception);
|
|
|
|
+ } else {
|
|
|
|
+ throw new RemoteOperationFailedException(message);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
returnFile = saveFileWithParent(parentFile, context);
|
|
returnFile = saveFileWithParent(parentFile, context);
|