Skip to content

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

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

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

Conversation

@daniele-verducci

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

Copy link
Copy Markdown
Contributor

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:

  • 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.

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:

  • Create a folder
  • Upload a file
  • Go offline (e.g. airplane mode)
  • Upload a second time the same, unmodified file
  • Go online
  • A conflict notification is shown
  • Click resolve, note the dialog: it says folder conflict, and the dates and sizes are wrong
  • Select both versions and click ok
  • Notice the remote version is overwritten by the local one. At the end you are left with a single file in the folder instead of two.

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

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

Comment thread app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java Outdated
Comment thread app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java Outdated
Comment thread app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt Outdated
Comment thread app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt Outdated
@daniele-verducci

Copy link
Copy Markdown
Contributor Author

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.
Basically, before the last 3 commits :

  • Create a folder
  • Upload a file
  • Go offline (e.g. airplane mode)
  • Upload a second time the same, unmodified file
  • Go online
  • A conflict notification is shown
  • Click resolve, note the dialog: it says folder conflict, and the dates and sizes are wrong
  • Select both versions and click ok
  • Notice the remote version is overwritten by the local one. At the end you are left with a single file in the folder instead of two.

So, the last commits fixes the dialog content and the overwrite. If approved, will close #17589 .

Thank you!

@alperozturk96

Copy link
Copy Markdown
Collaborator

/backport to stable-35.0.x

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/34466906550/artifacts/10150066862
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)

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit c2a8b76
Version 17590
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@daniele-verducci

Copy link
Copy Markdown
Contributor Author

Hey @alperozturk96 , thanks for the review and the suggestion! I applied them, now I wait for the CI to run.

@alperozturk96
alperozturk96 force-pushed the fix/internal-104835 branch 2 times, most recently from e2016d8 to 3f492ce Compare September 16, 2026 13:48
Comment thread app/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.kt Outdated
Comment thread app/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java Outdated
val remoteModified = this.modificationTimestamp / MS_IN_SECOND // Unix time in milliseconds
remoteName == localName &&
remoteSize == localSize &&
remoteCreated == localCreated &&

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.

How come remoteCreated and localCreated time can be same? We receive the remote file from server then write into our DB.

Scenario 1:

File created from other client, remote creating date written in the server's DB and Android client writes that and compare against the potentially exists local file this can be same file but creating time can be different.

Scenario 2:

File created from Android client does server stores Android's creation time exactly or stores based on server's creation time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. Not sure about this, i looked into it with the debugger:

  • file created from other client and overwritten by android client while offline: remoteCreated = 0, localCreated = 1789640828
  • file created from android client, then re-uploaded while offline: remoteCreated = 1789392966, localCreated = 1789392966
    (This is called by createPendingFile, so it's never called if the app is online)

I checked why remoteCreated isn't populated: it is, but it's already 0 in RemoteFile

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>
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>
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>
Signed-off-by: daniele-verducci <daniele.verducci@nextcloud.com>
@github-actions

Copy link
Copy Markdown

stable22-IT test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

Copy link
Copy Markdown

master-IT test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

Copy link
Copy Markdown

stable35-IT test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

Copy link
Copy Markdown

test-Unit test failed, but no output was generated. Maybe a preliminary stage failed.

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.

2 participants