Skip to content

[BUG] Offline Photos/Videos Not Syncing Correctly #4733

Open

Description

@alexknop

Actual behaviour

-Observing issues trying to save a folder offline with various photos and videos in them
-It seems local eTag of these photos, for example, can be just "" and the localModificationTimestamp is more recent. Even though the picture may just have been opened, but not actually modified. This triggers reuploads/redownloads when syncing.

Image

Expected behaviour

-All photos/videos on the server should download successfully and not re-upload any old photos.

Steps to reproduce

  1. Place a collection of photos and videos on the server in one folder
  2. Set folder offline
  3. Observe synchronization/downloading conflicts
  4. Observe a fileToSynchronize where eTag is "" and localModificationTimestamp is recent, which triggers changedLocally and changedRemotely in SynchronizeFileUseCase.kt

Can this problem be reproduced with the official owncloud server?
(url: https://ocis.ocis.master.owncloud.works, user: einstein, password: relativity)

Environment data

Android version:
16
Device model:
Pixel 10
Stock or customized system:
Stock
ownCloud app version:
4.7.0
ownCloud server version:
10.18.0

Logs

Web server error log

Not seeing a lot of logs regarding this file from today:

192.168.1.5 - alex [15/Nov/2025:12:22:49 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251109_043929876.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"
192.168.1.5 - alex [15/Nov/2025:12:23:08 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251109_043929876.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"
192.168.1.5 - alex [15/Nov/2025:12:23:11 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251105_195209298.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"

ownCloud log (data/owncloud.log)

192.168.1.5 - alex [15/Nov/2025:12:22:49 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251109_043929876.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"
192.168.1.5 - alex [15/Nov/2025:12:23:08 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251109_043929876.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"
192.168.1.5 - alex [15/Nov/2025:12:23:11 +0000] "PROPFIND /remote.php/dav/files/alex/Photos/Photos%20from%202025/PXL_20251105_195209298.mp4 HTTP/1.1" 207 1724 "-" "Mozilla/5.0 (Android) ownCloud-android/4.6.2"

Activity

  1. jesmrec commented on Dec 9, 2025

    @jesmrec
    Member

    Thanks for opening @alexknop, will check it. Just a couple of details. You mentioned 10.18.0, is that right? latest released version (vanilla) of oC10 is 10.16.0.

    Conflicts arise when you set the folder as "available offline" in device (your step 2) and are marked with a white cross over red background, right? just to be sure we are on the same page.

  2. alexknop commented on Dec 9, 2025

    @alexknop
    ContributorAuthor

    Hello @jesmrec thanks for getting to this so quickly. I should clarify that I am running on server version 10.16.
    I'm going to test this on a folder containing less photos and videos. I have hundreds of them in this folder, and when I set a breakpoint to capture one instance where re-uploading would happen, I can't scroll on my phone to check if that file has the red X. However, I was noticing multiple photos and videos in my folder with the red X already.
    In the meantime, I am running this modified code and it appears to be working for me. No reuploads or red Xs:

                    // 3. Check if file has changed locally
                    val changedLocally = fileToSynchronize.localModificationTimestamp > fileToSynchronize.lastSyncDateForData!! && (!fileToSynchronize
                        .isImage)
                    Timber.i("Local file modification timestamp :${fileToSynchronize.localModificationTimestamp}" +
                            " and last sync date for data :${fileToSynchronize.lastSyncDateForData}")
                    Timber.i("So it has changed locally: $changedLocally")
    
                    // 4. Check if file has changed remotely
                    val changedRemotely = fileToSynchronize.etag != "" && (serverFile.etag != fileToSynchronize.etag)
                    Timber.i("Local etag :${fileToSynchronize.etag} and remote etag :${serverFile.etag}")
                    Timber.i("So it has changed remotely: $changedRemotely")
    
  3. jesmrec commented on Dec 10, 2025

    @jesmrec
    Member

    thanks, will review it. CC @joragua

  4. joragua commented on Dec 12, 2025

    @joragua
    Member

    Hi @alexknop! I cannot reproduce the problem that you mentioned. These are the steps that I followed:

    1. Create a folder and upload some files (images, PDFs...)
    2. Set the folder as available offline
    3. Open the folder and check the status of the files

    All files show the pink check badge and not the white cross on a red background as you described. Could you check the steps above and let me know if I'm missing something? If possible, could you also attach a video showing the bug? Thanks! 🙌🏻

  5. alexknop commented on Dec 13, 2025

    @alexknop
    ContributorAuthor

    Ok @joragua so i was able to reproduce.

    localModificationTimestamp: 2025-12-11 19:20:07.859 EST
    lastSyncDateForData: 2025-12-11 19:20:00.492 EST

    Which is triggering changedLocally.

    before downloading:

    frankel:/data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos $ ls -lah Photos\ from\ 2023
    
    Photos from 2023:
    total 7
    drwx------  2 u0_a380 u0_a380  20K 2025-12-12 18:16 .
    drwx------ 10 u0_a380 u0_a380 3.3K 2025-12-12 18:59 ..
    frankel:/data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos $
    
    12-12 19:19:58.476  9233  9734 D (ReadRemoteFileOperation.kt:75): I: Read remote file /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg with status 207
    12-12 19:19:58.478  9233  9734 D (SynchronizeFileUseCase.kt:70): I: File 22-02-17 23-13-57 0656.jpg is not downloaded. Let's download it
    12-12 19:19:58.509  9233  9734 D (DownloadFileUseCase.kt:103): I: Download of 22-02-17 23-13-57 0656.jpg has been enqueued.
    12-12 19:20:00.492  9233 10676 D (DownloadRemoteFileOperation.kt:82): I: Download of /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg to /data/user/0/com.owncloud.android.debug/files/owncloud/tmp/[email protected]%3A8080/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg - HTTP status code: 207
    12-12 19:20:01.045  9233 11092 D (ReadRemoteFileOperation.kt:75): I: Read remote file /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg with status 207
    12-12 19:20:01.046  9233 11092 D (SynchronizeFileUseCase.kt:70): I: File 22-02-17 23-13-57 0656.jpg is not downloaded. Let's download it
    12-12 19:20:01.871  9233 11092 D (DownloadFileUseCase.kt:103): I: Download of 22-02-17 23-13-57 0656.jpg has been enqueued.
    12-12 19:20:07.866  9233  9283 D (DownloadRemoteFileOperation.kt:82): I: Download of /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg to /data/user/0/com.owncloud.android.debug/files/owncloud/tmp/[email protected]%3A8080/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg - HTTP status code: 207
    12-12 19:20:17.918  9233 11139 D (ReadRemoteFileOperation.kt:75): I: Read remote file /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg with status 207
    12-12 19:25:49.094  9233 11139 D (SynchronizeFileUseCase.kt:115): I: File 22-02-17 23-13-57 0656.jpg has changed locally. Let's upload the new version
    12-12 19:25:49.097  9233 11139 D (UploadFileInConflictUseCase.kt:61): D: Upload file in conflict params: [email protected]:8080 | /data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg | /Photos/Photos from 2023/ 
    12-12 19:25:49.110  9233 11139 D (UploadFileInConflictUseCase.kt:97): I: Upload of /Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg has been stored in the uploads database with id: 362
    12-12 19:25:49.113  9233 11139 D (UploadFileInConflictUseCase.kt:130): I: Plain upload of /data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg has been enqueued.
    12-12 19:25:49.203  9233  9293 D (UploadFileFromFileSystemWorker.kt:154): D: Upload info: OCTransfer(id=362, localPath=/data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg, remotePath=/Photos/Photos from 2023/22-02-17 23-13-57 0656.jpg, [email protected]:8080, fileSize=3190619, status=TRANSFER_QUEUED, localBehaviour=COPY, forceOverwrite=true, transferEndTimestamp=null, lastResult=null, createdBy=ENQUEUED_BY_USER, transferId=null, spaceId=null, sourcePath=null)
    
    frankel:/data/user/0/com.owncloud.android.debug/files/owncloud/[email protected]%3A8080/Photos $ ls -lah Photos\ from\ 2023 | grep 0656                                                                             
    -rw-------  1 u0_a380 u0_a380 3.0M 2025-12-12 19:20 22-02-17 23-13-57 0656.jpg
    

    From 19:20 to 19:25 I was sitting at my breakpoint and taking the timestamp values.

    Here is the video.

    https://drive.google.com/file/d/1S59aIWYYBumTz_6CS9xiwhAYNHWQHUuW/view?usp=drive_link

    And all logcat entries from this time period:

    partiallogcat.txt

  6. jesmrec commented on Dec 16, 2025

    @jesmrec
    Member

    requested access to the video.

  7. jesmrec commented on Dec 17, 2025

    @jesmrec
    Member

    @alexknop thanks for all the info, i was able to reproduce the problem, will check it together with your suggested solution.

  8. alexknop commented on Dec 17, 2025

    @alexknop
    ContributorAuthor

    @jesmrec
    Thank you, however my solution is just a bandaid. There's likely a better solution. Especially considering my logs are showing the file downloaded multiple times. I didn't really take the time to see what other functions are being called to cause this.

  9. joragua commented on Dec 23, 2025

    @joragua
    Member

    @alexknop, did you try waiting after setting the folder as available offline, without opening the folder or navigating through the app? 🤔 Just to confirm whether the issue might be related to the additional sync that runs separately from the available offline sync.

    That means:

    1. Set the folder as available offline
    2. Don't interact with the device and wait until the folder is synchronized
  10. alexknop commented on Jan 7, 2026

    @alexknop
    ContributorAuthor

    @joragua no, I am not seeing this while not interacting with the folder.

  11. added this to the 4.8 - Current milestone on Jan 9, 2026
  12. DeepDiver1975 commented on Jul 3, 2026

    @DeepDiver1975
    Contributor

    Confirmed bug. Located in the available-offline re-sync path.

    Root cause — SynchronizeFileUseCase.kt (master):

    • L75: changedLocally = fileToSynchronize.localModificationTimestamp > lastSyncDateForData\!\!
    • localModificationTimestamp is the on-disk file mtime, read live: File(storagePath).lastModified() (OCFile.kt L174-180).
    • lastSyncDateForData is a wall-clock snapshot taken with System.currentTimeMillis() in DownloadFileWorker.kt L208/L215, not derived from the file's on-disk mtime.

    These are two independent clocks. Nothing sets the downloaded file's mtime to match lastSyncDateForData (no setLastModified anywhere in the download path — temp file is written then renameTo in moveTemporalFileToFinalLocation(), DownloadFileWorker.kt L182-197, which leaves the OS-assigned mtime). So the on-disk mtime can land after the sampled lastSyncDateForData, making changedLocally fire on a file that was only downloaded, never edited. This matches @alexknop's captured values (mtime 19:20:07.859 > lastSyncDateForData 19:20:00.492) and the resulting spurious UploadFileInConflictUseCase reupload.

    Notes:

    • Not image-specific. The \!isImage band-aid @alexknop tested masks it for images but leaves videos and any other file exposed; @alexknop already flagged it as a band-aid.
    • Per @alexknop's last comment: only reproduces during active navigation of the folder while it syncs, not on an untouched wait. Consistent with the two-clock race — repeated propfind/download passes (visible in the log, same file read/downloaded several times) widen the window between the mtime write and the lastSyncDateForData snapshot.

    Suggested direction (not a prescription): make the "changed locally" check compare against the file's own recorded state rather than a separate wall clock — e.g. store the on-disk mtime at save time and compare mtime-vs-mtime, or set the downloaded file's mtime deterministically so localModificationTimestamp and lastSyncDateForData share a basis.

    🤖 Generated with Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions