浏览代码

Remove unique upload by his ID when it already exists in current ones

Juan Carlos González Cabrero 9 年之前
父节点
当前提交
467071321f

+ 19 - 0
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -326,6 +326,25 @@ public class UploadsStorageManager extends Observable {
         return result;
     }
 
+    /**
+     * Remove a specific upload given his unique ID.
+     *
+     * @param uploadId       unique ID of the upload.
+     * @return true when the upload entry was removed
+     */
+    public int removeUpload(long uploadId) {
+        int result = getDB().delete(
+            ProviderTableMeta.CONTENT_URI_UPLOADS,
+            ProviderTableMeta._ID + "=?",
+            new String[]{String.valueOf(uploadId)}
+        );
+        Log_OC.d(TAG, "delete returns " + result + " for upload with ID " + uploadId);
+        if (result > 0) {
+            notifyObserversNow();
+        }
+        return result;
+    }
+
 
     public OCUpload[] getAllStoredUploads() {
         return getUploads(null, null);

+ 1 - 1
src/com/owncloud/android/files/services/FileUploader.java

@@ -525,7 +525,7 @@ public class FileUploader extends Service
                         uploadKey = putResult.first;
                         requestedUploads.add(uploadKey);
                     } else {
-                        mUploadsStorageManager.removeUpload(account.name, files[i].getRemotePath());
+                        mUploadsStorageManager.removeUpload(newUpload.getOCUploadId());
                     }
                     // else, file already in the queue of uploads; don't repeat the request
                 }