Browse Source

Update local path of upload, for consistent move operations

Juan Carlos González Cabrero 9 years ago
parent
commit
94aaff3af8
1 changed files with 11 additions and 7 deletions
  1. 11 7
      src/com/owncloud/android/datamodel/UploadsStorageManager.java

+ 11 - 7
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -168,10 +168,10 @@ public class UploadsStorageManager extends Observable {
      */
     public int updateUploadStatus(OCUpload ocUpload) {
         return updateUploadStatus(ocUpload.getUploadId(), ocUpload.getUploadStatus(),
-                ocUpload.getLastResult(), ocUpload.getRemotePath());
+                ocUpload.getLastResult(), ocUpload.getRemotePath(), ocUpload.getLocalPath());
     }
 
-    private int updateUploadInternal(Cursor c, UploadStatus status, UploadResult result, String remotePath) {
+    private int updateUploadInternal(Cursor c, UploadStatus status, UploadResult result, String remotePath, String localPath) {
 
         int r = 0;
         while (c.moveToNext()) {
@@ -188,6 +188,7 @@ public class UploadsStorageManager extends Observable {
             upload.setUploadStatus(status);
             upload.setLastResult(result);
             upload.setRemotePath(remotePath);
+            upload.setLocalPath(localPath);
             if (status == UploadStatus.UPLOAD_SUCCEEDED) {
                 upload.setUploadEndTimestamp(Calendar.getInstance().getTimeInMillis());
             }
@@ -208,7 +209,7 @@ public class UploadsStorageManager extends Observable {
      * @param result new result of upload operation
      * @return 1 if file status was updated, else 0.
      */
-    public int updateUploadStatus(long id, UploadStatus status, UploadResult result, String remotePath) {
+    public int updateUploadStatus(long id, UploadStatus status, UploadResult result, String remotePath, String localPath) {
         //Log_OC.v(TAG, "Updating "+filepath+" with uploadStatus="+status +" and result="+result);
 
         int returnValue = 0;
@@ -224,7 +225,7 @@ public class UploadsStorageManager extends Observable {
             Log_OC.e(TAG, c.getCount() + " items for id=" + id
                 + " available in UploadDb. Expected 1. Failed to update upload db.");
         } else {
-            returnValue = updateUploadInternal(c, status, result, remotePath);
+            returnValue = updateUploadInternal(c, status, result, remotePath, localPath);
         }
         c.close();
         return returnValue;
@@ -515,14 +516,16 @@ public class UploadsStorageManager extends Observable {
                         upload.getOCUploadId(),
                         UploadStatus.UPLOAD_SUCCEEDED,
                         UploadResult.UPLOADED,
-                        upload.getRemotePath()
+                        upload.getRemotePath(),
+                        upload.getStoragePath()
                 );
             } else {
                 updateUploadStatus(
                     upload.getOCUploadId(),
                     UploadStatus.UPLOAD_FAILED,
                     UploadResult.fromOperationResult(uploadResult),
-                    upload.getRemotePath());
+                    upload.getRemotePath(),
+                    upload.getStoragePath());
             }
         }
     }
@@ -555,7 +558,8 @@ public class UploadsStorageManager extends Observable {
                 upload.getOCUploadId(),
                 UploadStatus.UPLOAD_IN_PROGRESS,
                 UploadResult.UNKNOWN,
-                upload.getRemotePath()
+                upload.getRemotePath(),
+                upload.getStoragePath()
         );
     }