mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
implement isUploading for Upload Worker
Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
parent
f65601f69f
commit
8e141506ec
2 changed files with 25 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue