mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
UploadFileOperation: don't read entire list of uploads every time we want to update the size of just one
Wtf Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
044a321678
commit
f83c3aebdc
1 changed files with 12 additions and 21 deletions
|
@ -388,13 +388,7 @@ public class UploadFileOperation extends SyncOperation {
|
|||
mCancellationRequested.set(false);
|
||||
mUploadStarted.set(true);
|
||||
|
||||
for (OCUpload ocUpload : uploadsStorageManager.getAllStoredUploads()) {
|
||||
if (ocUpload.getUploadId() == getOCUploadId()) {
|
||||
ocUpload.setFileSize(0);
|
||||
uploadsStorageManager.updateUpload(ocUpload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateSize(0);
|
||||
|
||||
String remoteParentPath = new File(getRemotePath()).getParent();
|
||||
remoteParentPath = remoteParentPath.endsWith(OCFile.PATH_SEPARATOR) ?
|
||||
|
@ -567,13 +561,8 @@ public class UploadFileOperation extends SyncOperation {
|
|||
size = new File(mFile.getStoragePath()).length();
|
||||
}
|
||||
|
||||
for (OCUpload ocUpload : uploadsStorageManager.getAllStoredUploads()) {
|
||||
if (ocUpload.getUploadId() == getOCUploadId()) {
|
||||
ocUpload.setFileSize(size);
|
||||
uploadsStorageManager.updateUpload(ocUpload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
updateSize(size);
|
||||
|
||||
/// perform the upload
|
||||
if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
|
||||
|
@ -810,13 +799,7 @@ public class UploadFileOperation extends SyncOperation {
|
|||
size = new File(mFile.getStoragePath()).length();
|
||||
}
|
||||
|
||||
for (OCUpload ocUpload : uploadsStorageManager.getAllStoredUploads()) {
|
||||
if (ocUpload.getUploadId() == getOCUploadId()) {
|
||||
ocUpload.setFileSize(size);
|
||||
uploadsStorageManager.updateUpload(ocUpload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateSize(size);
|
||||
|
||||
// perform the upload
|
||||
if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
|
||||
|
@ -901,6 +884,14 @@ public class UploadFileOperation extends SyncOperation {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void updateSize(long size) {
|
||||
OCUpload ocUpload = uploadsStorageManager.getUploadById(getOCUploadId());
|
||||
if(ocUpload != null){
|
||||
ocUpload.setFileSize(size);
|
||||
uploadsStorageManager.updateUpload(ocUpload);
|
||||
}
|
||||
}
|
||||
|
||||
private void logResult(RemoteOperationResult result, String sourcePath, String targetPath) {
|
||||
if (result.isSuccess()) {
|
||||
Log_OC.i(TAG, "Upload of " + sourcePath + " to " + targetPath + ": " + result.getLogMessage());
|
||||
|
|
Loading…
Reference in a new issue