Fix conflicts for offline uploads when uploading same file again - #17590
daniele-verducci wants to merge 12 commits into
Conversation
|
@tobiasKaminsky should this be in milestone 35 or 36? |
|
APK file: https://github.com/nextcloud/android/actions/runs/34251212640/artifacts/10066358893 |
7ae46de to
aea7023
Compare
cbe3c19 to
ea79580
Compare
|
Hey @alperozturk96 , as anticipated I fixed also the missing case, so I re-requested your review. You can check just the last 4 (new) commits.
So, the last commits fixes the dialog content and the overwrite. If approved, will close #17589 . Thank you! |
|
/backport to stable-35.0.x |
804d2fd to
57df3dd
Compare
|
blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
APK file: https://github.com/nextcloud/android/actions/runs/34466906550/artifacts/10150066862 |
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>
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
…g etagOnServer field properly in UploadFileOperation Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
… edge cases Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
…d new name to the one used for online 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>
57df3dd to
e82ac43
Compare
| .forEach { dao.update(it) } | ||
| } | ||
|
|
||
| private fun updateOperationPath(newPath: String, nextOperation: OfflineOperationEntity): OfflineOperationEntity? = |
There was a problem hiding this comment.
private fun updateOperationPath(newPath: String, nextOperation: OfflineOperationEntity): OfflineOperationEntity? {
if (newPath == nextOperation.path) return null
val updatedType = when (val currentType = nextOperation.type) {
is OfflineOperationType.CreateFile -> currentType.copy(remotePath = newPath)
is OfflineOperationType.CreateFolder -> currentType.copy(path = newPath)
else -> currentType
}
return nextOperation.apply {
type = updatedType
path = newPath
}
}
| final OCFile existingFile = getFileByRemotePath(remotePath); | ||
| final File localFile = FileExtensionsKt.toFile(localPath); | ||
| if (FileExtensionsKt.isTheSameAs(existingFile, localFile)) { | ||
| // In case the same file was already uploaded, do not overwrite it to avoid triggering a conflict |
There was a problem hiding this comment.
Just a tiny thing :) No need to have another comment since we have Log_OC.i. You can update it to cover both.
| String newPath = parentFolder.getDecryptedRemotePath() + newFolderName + OCFile.PATH_SEPARATOR; | ||
| moveLocalFile(file, newPath, parentFolder.getDecryptedRemotePath()); | ||
| offlineOperationsRepository.updateNextOperations(entity); | ||
| final String newPath = UploadFileOperation.getNewAvailableRemotePath( |
There was a problem hiding this comment.
Good improvement with getNewAvailableRemotePath.
moveLocalFile was unnecessary here since file is already there.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
📱 QA build
The QA build installs alongside a released Nextcloud app, so you can keep Downloading the file requires a GitHub account, so open this link on the |
Fixes the following two problems:
Conflict message being shown for offline uploads when the offline-uploaded file is the same as the remote
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.
Remote file overwritted by local file when selecting "keep both" after offline upload
This PR does fix this this second issue: #17589
How to repro:
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)