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

This commit is contained in:
Juan Carlos González Cabrero 2016-03-28 11:10:27 +02:00
parent cbf619be77
commit 467071321f
2 changed files with 20 additions and 1 deletions

View file

@ -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);

View file

@ -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
}