diff --git a/app/src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java b/app/src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java index 0aac8b984a..d188c9523b 100644 --- a/app/src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java +++ b/app/src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java @@ -345,6 +345,24 @@ public class UploadsStorageManager extends Observable { return getUploads(null, (String[]) null); } + public OCUpload getUploadByRemotePath(String remotePath){ + OCUpload result = null; + Cursor cursor = getDB().query( + ProviderTableMeta.CONTENT_URI_UPLOADS, + null, + ProviderTableMeta.UPLOADS_REMOTE_PATH + "=?", + new String[]{remotePath}, + ProviderTableMeta.UPLOADS_REMOTE_PATH+ " ASC"); + + if (cursor != null) { + if (cursor.moveToFirst()) { + result = createOCUploadFromCursor(cursor); + } + } + Log_OC.d(TAG, "Retrieve job " + result + " for remote path " + remotePath); + return result; + } + public @Nullable OCUpload getUploadById(long id) { OCUpload result = null; diff --git a/app/src/main/java/com/owncloud/android/files/services/FileUploader.java b/app/src/main/java/com/owncloud/android/files/services/FileUploader.java index a068b89ba1..9f3f6ac9f0 100644 --- a/app/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/app/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -1250,14 +1250,13 @@ public class FileUploader extends Service } if (useFilesUploadWorker(getApplicationContext())){ // Not same as for service because upload list is "created" on the spot in the worker and not available here - /*** TODO: LEADS TO PERFORMANCE ISSUES -> Find better way - * OCUpload upload = mUploadsStorageManager.getUploadByRemotePath(file.getRemotePath()); - * if (upload == null){ - * return false; - * } - * return upload.getUploadStatus() == UploadStatus.UPLOAD_IN_PROGRESS; - */ - return false; + + OCUpload upload = mUploadsStorageManager.getUploadByRemotePath(file.getRemotePath()); + if (upload == null){ + return false; + } + return upload.getUploadStatus() == UploadStatus.UPLOAD_IN_PROGRESS; + }else{ return mPendingUploads.contains(user.getAccountName(), file.getRemotePath()); }