Skip to content

Fix conflicts for offline uploads when uploading same file again - #17590

Open
daniele-verducci wants to merge 5 commits into
masterfrom
fix/internal-104835
Open

Fix conflicts for offline uploads when uploading same file again#17590
daniele-verducci wants to merge 5 commits into
masterfrom
fix/internal-104835

Conversation

@daniele-verducci

@daniele-verducci daniele-verducci commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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:

  • Create a folder
  • Upload a file
  • Go offline (e.g. airplane mode)
  • Upload a second time the same, unmodified file
  • Go online
  • A conflict message is shown

Now execute the same actions in a new folder without going offline:

  • A conflict message is NOT shown

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

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
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>
@daniele-verducci daniele-verducci added this to the Nextcloud App 36.0.0 milestone Sep 8, 2026
@daniele-verducci daniele-verducci changed the title Fix/internal 104835 Fix conflicts for offline uploads when uploading same file again Sep 8, 2026
@daniele-verducci daniele-verducci removed this from the Nextcloud App 36.0.0 milestone Sep 8, 2026
@daniele-verducci

Copy link
Copy Markdown
Contributor Author

@tobiasKaminsky should this be in milestone 35 or 36?

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/34251212640/artifacts/10066358893
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codacy

SpotBugs

CategoryBaseNew
Bad practice3535
Correctness5858
Dodgy code195195
Experimental11
Malicious code vulnerability22
Multithreaded correctness2626
Performance3737
Security1919
Total373373

saveFileWithParent(file, MainApp.getAppContext());
}

private boolean fileIsTheSame(OCFile ocFile, File localFile) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use the FileExtensions.kt?

) {
final OCFile existingFile = getFileByRemotePath(remotePath);
if (existingFile != null) {
final File localFile = new File(localPath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UploadFileOperation.handleLocalBehaviour(temporalFile, expectedFile, originalFile, client); already saves the file why we are checking here in worker again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline upload conflicts resolution overwrites the remote file even if the user select to keep both

2 participants