android icon indicating copy to clipboard operation
android copied to clipboard

[BUG] File as a folder when syncing

Open jesmrec opened this issue 10 months ago • 3 comments

Steps to reproduce

  1. Add a txt file to the account
  2. In app, download the file and go back to the list of files (marked with green)
  3. In the web, modify the txt file and save it.
  4. In app, pull to refresh
  5. When the file is syncing (blue badge), click on it to open

Actual behaviour

I noticed two different behaviours (it's a bit random)

  1. File is handled like a folder showing No files in here
  2. File is marked as conflicted (might be related with https://github.com/owncloud/android/issues/4733 ¿?)

I caught a video with behaviour 1.

https://github.com/user-attachments/assets/7f238089-73a5-4992-a815-25aa1cd828a9

This is not an easy one to reproduce and it does not happen every time. That's bad.

For that reason, my suggestion to avoid such bad cases is "blocking" the file while the blue icon is there. It would apply only to files (a syncing folder can be browsed, but not the files that are being synced).

Reproduced with both oCIS and oC10, using the app version `v4.7.0'

Devices: Xiaomi Redmi Note 13 Samsung Galaxy Tab A8

jesmrec avatar Jan 19 '26 10:01 jesmrec

Hey, @jesmrec thank you for reporting this. Please assign it to me, if needed. thx

dataCenter430 avatar Mar 05 '26 18:03 dataCenter430

you can work on it @dataCenter430.

As you are starting to contribute, please take a look to our CONTRIBUTING file to get some tips about how to contribute. Please pay attention to:

  • branch naming
  • commit naming
  • git model (we use rebase instead of merge)

any question, please don't hesitate to reach us. We are more than welcome!

jesmrec avatar Mar 06 '26 07:03 jesmrec

Triage: valid bug, but the "file opens as a folder" root cause can't be pinned to a deterministic client-code defect — it needs the offending PROPFIND response / DB state. Notes from current master (51aa1fe):

How the folder-vs-file decision is made

  • Tap routing is purely ocFile.isFolder, with no guard on sync state — MainFileListFragment.kt:1567 (onItemClick): if (ocFile.isFolder) updateFolderToDisplay(...) else onFileClicked(...).
  • isFolder is derived only from mimeType — OCFile.kt: mimeType.isOneOf(MIME_DIR, MIME_DIR_UNIX), where MIME_DIR = "DIR" / MIME_DIR_UNIX = "httpd/unix-directory" (MimeTypeConstants.kt:24-25).

So behaviour (1) "handled like a folder / No files in here" happens iff the OCFile's mimeType is DIR/httpd/unix-directory at tap time.

Where mimeType comes from

  • Remote→local is a straight passthrough: OCRemoteFileDataSource.toModel() copies mimeType unchanged.
  • PROPFIND parsing: RemoteFile.mimeType defaults to "DIR" and is only overwritten when a non-null getcontenttype is present (RemoteFile.kt, getRemoteFileFromDav → is GetContentType -> property.type?.let { remoteFile.mimeType = it }). A file whose PROPFIND response carries no/empty getcontenttype would keep mimeType = "DIR" → classified as a folder.

I could not find any client path that deterministically rewrites an existing file's mimeType to a folder mime during refresh (copyLocalPropertiesFrom does not touch mimeType). So the misclassification depends on the specific PROPFIND response or a transient row state during the refresh window — consistent with the "random, hard to reproduce" symptom. Behaviour (2) is a normal local+remote conflict (SynchronizeFileUseCase sets etagInConflict), plausibly the same #4733.

To locate this, a network capture (PROPFIND multistatus for the file, both oC10 and oCIS) at the moment of the bad refresh would confirm whether getcontenttype is missing/empty in that response.

On the proposed mitigation — blocking tap while the blue badge is shown is sound and is a small, localized change: onItemClick already receives OCFileWithSyncInfo (isSynchronizing), so it can short-circuit taps on a non-folder that is currently synchronizing. That guards the symptom even if the underlying mimeType glitch isn't fixed.

🤖 Generated with Claude Code

DeepDiver1975 avatar Jul 03 '26 13:07 DeepDiver1975