You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Creating/deleting file via DocumentProvider is not working as expected #4638
Hi @donmor! i did a check with Tiddloid (installed from F-droid) and could not reproduce the problem. Tiddloid has documents provider access and it is able to save a new wiki file in the chosen folder.
I recorded a video with the steps i did to create the new file. Let me know if there is something different by comparing to your case, so that we can scope where the problem could be:
Confirmed bug in the app's SAF DocumentsProvider. Located cause: createDocument returns the sentinel document ID "-1" for every newly-created file instead of a real, persistable ID.
DocumentsStorageProvider.kt (master):
createFile() builds fileToUpload but does not persist it, and returns NONEXISTENT_DOCUMENT_ID (= "-1") — L498-518, L615. The real DB id only exists after the async upload+sync completes in openDocument's close listener (L143-154).
SAF hands that "-1" back to the calling app as the created document's ID. That's the -1 "path" the reporter sees; genuinely-persisted files get positive ids.
Consequences when the caller reuses the returned/persisted URI:
openDocument("-1", …) → uploadOnly branch (L105) always resolves to the last fileToUpload, not the file the caller meant — so the saved file "can't be accessed again until reopened from SAF".
Fix direction: createDocument must return the actual document ID of the created file (SAF requires a stable ID usable for subsequent open/delete/query), not the "-1" sentinel. That likely means the entry must exist in the DB (or the upload be awaited) before returning, so the returned ID resolves in queryDocument/openDocument/deleteDocument.
Scope note: distinct from the copy/move-between-accounts DocumentProvider bugs reopened 2026-07-01 (#2658/#2659/#2662) — same subsystem, different code path (create/delete of a new file vs. cross-account copy/move).
Activity
jesmrec commentedon Jul 14, 2025
Hi @donmor! i did a check with Tiddloid (installed from F-droid) and could not reproduce the problem. Tiddloid has documents provider access and it is able to save a new wiki file in the chosen folder.
I recorded a video with the steps i did to create the new file. Let me know if there is something different by comparing to your case, so that we can scope where the problem could be:
Screen_recording_20250714_091518.mp4
donmor commentedon Jul 14, 2025
Looks like my description was wrong. Edited.
donmor commentedon Jul 14, 2025
BTW I can't find ownCloud in SAF "open directory" interface. Will it be an option to enable directory managing / literal path for SAF?
jesmrec commentedon Jul 14, 2025
Now, i was able to reproduce that problem, saved file was not enabled for opening/removing. Will check this.
that's not implemented ftm. Only available for single files (am i right, @joragua?).
joragua commentedon Jul 14, 2025
Yes, right! It's only available for single files. Regarding the bug, we will take a look and see what's going on! 🍻
DeepDiver1975 commentedon Jul 2, 2026
Confirmed bug in the app's SAF
DocumentsProvider. Located cause:createDocumentreturns the sentinel document ID"-1"for every newly-created file instead of a real, persistable ID.DocumentsStorageProvider.kt(master):createFile()buildsfileToUploadbut does not persist it, and returnsNONEXISTENT_DOCUMENT_ID(= "-1") — L498-518, L615. The real DB id only exists after the async upload+sync completes inopenDocument's close listener (L143-154)."-1"back to the calling app as the created document's ID. That's the-1"path" the reporter sees; genuinely-persisted files get positive ids.Consequences when the caller reuses the returned/persisted URI:
openDocument("-1", …)→uploadOnlybranch (L105) always resolves to the lastfileToUpload, not the file the caller meant — so the saved file "can't be accessed again until reopened from SAF".deleteDocument("-1")→getFileByIdOrException((-1).toInt())→GetFileByIdUseCase(-1)finds nothing →FileNotFoundException(L402-404, L595-599). Delete fails.Fix direction:
createDocumentmust return the actual document ID of the created file (SAF requires a stable ID usable for subsequent open/delete/query), not the"-1"sentinel. That likely means the entry must exist in the DB (or the upload be awaited) before returning, so the returned ID resolves inqueryDocument/openDocument/deleteDocument.Scope note: distinct from the copy/move-between-accounts DocumentProvider bugs reopened 2026-07-01 (#2658/#2659/#2662) — same subsystem, different code path (create/delete of a new file vs. cross-account copy/move).
🤖 Generated with Claude Code