implement isUploading for Upload Worker

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2023-11-28 11:16:39 +01:00 committed by Jonas Mayer
parent f65601f69f
commit 8e141506ec
2 changed files with 25 additions and 8 deletions

View file

@ -345,6 +345,24 @@ public class UploadsStorageManager extends Observable {
return getUploads(null, (String[]) null); 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 public @Nullable
OCUpload getUploadById(long id) { OCUpload getUploadById(long id) {
OCUpload result = null; OCUpload result = null;

View file

@ -1250,14 +1250,13 @@ public class FileUploader extends Service
} }
if (useFilesUploadWorker(getApplicationContext())){ if (useFilesUploadWorker(getApplicationContext())){
// Not same as for service because upload list is "created" on the spot in the worker and not available here // 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()); OCUpload upload = mUploadsStorageManager.getUploadByRemotePath(file.getRemotePath());
* if (upload == null){ if (upload == null){
* return false; return false;
* } }
* return upload.getUploadStatus() == UploadStatus.UPLOAD_IN_PROGRESS; return upload.getUploadStatus() == UploadStatus.UPLOAD_IN_PROGRESS;
*/
return false;
}else{ }else{
return mPendingUploads.contains(user.getAccountName(), file.getRemotePath()); return mPendingUploads.contains(user.getAccountName(), file.getRemotePath());
} }