diff --git a/src/com/owncloud/android/datamodel/UploadsStorageManager.java b/src/com/owncloud/android/datamodel/UploadsStorageManager.java index 0d40afca2a..0ebaa40569 100644 --- a/src/com/owncloud/android/datamodel/UploadsStorageManager.java +++ b/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); diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 28a196cd29..b66dd6893b 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/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 }