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

View file

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