<string name="conflict_overwrite">Overwrite</string>
<string name="conflict_dont_upload">Don\'t upload</string>
+ <!-- we need to improve the communication of errors to the user -->
+ <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local directory</string>
+
</resources>
import com.owncloud.android.operations.ChunkedUploadFileOperation;
import com.owncloud.android.operations.RemoteOperationResult;
import com.owncloud.android.operations.UploadFileOperation;
+import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.ui.activity.FileDetailActivity;
import com.owncloud.android.ui.fragment.FileDetailFragment;
import com.owncloud.android.utils.OwnCloudVersion;
finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
// TODO put something smart in the contentIntent below
finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
+
+ String content = null;
+ if (uploadResult.getCode() == ResultCode.LOCAL_STORAGE_FULL ||
+ uploadResult.getCode() == ResultCode.LOCAL_STORAGE_NOT_COPIED) {
+ // TODO we need a class to provide error messages for the users from a RemoteOperationResult and a RemoteOperation
+ content = String.format(getString(R.string.error__upload__local_file_not_copied), (new File(upload.getStoragePath())).getName(), getString(R.string.app_name));
+ } else {
+ content = String.format(getString(R.string.uploader_upload_failed_content_single), (new File(upload.getStoragePath())).getName());
+ }
finalNotification.setLatestEventInfo( getApplicationContext(),
getString(R.string.uploader_upload_failed_ticker),
- String.format(getString(R.string.uploader_upload_failed_content_single), (new File(upload.getStoragePath())).getName()),
+ content,
finalNotification.contentIntent);
mNotificationManager.notify(R.string.uploader_upload_failed_ticker, finalNotification);
mDataTransferListeners.add(listener);
}
-
@Override
protected RemoteOperationResult run(WebdavClient client) {
RemoteOperationResult result = null;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
}
+
+ } catch (Exception e) {
+ result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_COPIED);
+ return result;
+
} finally {
try {
if (in != null) in.close();
}
expectedFile = new File(mFile.getStoragePath());
if (!expectedFile.equals(fileToMove) && !fileToMove.renameTo(expectedFile)) {
- result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED);
- return result;
+ mFile.setStoragePath(null); // forget the local file
+ // by now, treat this as a success; the file was uploaded; the user won't like that the local file is not linked, but this should be a veeery rare fail;
+ // the best option could be show a warning message (but not a fail)
+ //result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED);
+ //return result;
}
}
}