Fix conflicts for offline uploads when uploading same file again - #17590
Fix conflicts for offline uploads when uploading same file again#17590daniele-verducci wants to merge 5 commits into
Conversation
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
… already uploaded file Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
|
@tobiasKaminsky should this be in milestone 35 or 36? |
|
APK file: https://github.com/nextcloud/android/actions/runs/34251212640/artifacts/10066358893 |
|
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
| saveFileWithParent(file, MainApp.getAppContext()); | ||
| } | ||
|
|
||
| private boolean fileIsTheSame(OCFile ocFile, File localFile) { |
There was a problem hiding this comment.
Could you please use the FileExtensions.kt?
| ) { | ||
| final OCFile existingFile = getFileByRemotePath(remotePath); | ||
| if (existingFile != null) { | ||
| final File localFile = new File(localPath); |
There was a problem hiding this comment.
You can also move this to the FileExtensions.kt and use localPath.toFile() function.
Then if block fully comes from the extension file.
| break | ||
| } | ||
|
|
||
| if (result.isSuccess && result.resultData is String) { |
There was a problem hiding this comment.
What result.resultData can be? Always String or something else also possible?
| // Update the remote etag to avoid conflict when uploading same file, both in online and offline uploads | ||
| val file = operation.storageManager.getFileByRemotePath(upload.remotePath) | ||
| file?.etagOnServer = result.resultData.toString() | ||
| operation.storageManager.saveFile(file) |
There was a problem hiding this comment.
UploadFileOperation.handleLocalBehaviour(temporalFile, expectedFile, originalFile, client); already saves the file why we are checking here in worker again?
Fixes the conflict message being shown for offline uploads when the offline-uploaded file is the same as the remote. This makes the behavior aligned with what happens online.
How to repro:
Now execute the same actions in a new folder without going offline:
This is because the offline upload erases the etag_on_server field for the already existing db entry.
This PR fixes this issue.
This PR does NOT fix #17589
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)