fix(file-provider): prevent duplicate folder when editor saves to renamed path.#10136
Closed
camilasan wants to merge 2 commits into
Closed
fix(file-provider): prevent duplicate folder when editor saves to renamed path.#10136camilasan wants to merge 2 commits into
camilasan wants to merge 2 commits into
Conversation
…amed path. LibreOffice and similar cross-platform editors do not implement NSFilePresenter, so they receive no path-change notification when the parent folder is renamed. On the next save they write to the old path, which causes macOS File Provider to call createItem for the old folder name. Without this change the extension issues a server MKCOL for the old path, producing a duplicate folder. RecentRenameTracker records the old remote path → ocId mapping with a 60s TTL whenever renameDirectoryAndPropagateToChildren runs. createNewFolder checks the cache before MKCOL; if the path was recently renamed it returns the existing (renamed) Item instead of creating a new one. Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: Camila Ayres <hello@camilasan.com>
…t mock. Bundle.main.bundleIdentifier is nil when running under swift test. Assisted-by: Claude:claude-sonnet-4-5 Signed-off-by: Camila Ayres <hello@camilasan.com>
Member
Author
|
/backport to stable-33.0 |
Member
Author
|
/backport to stable-4.0 |
5 tasks
Contributor
|
Artifact containing the AppImage: nextcloud-appimage-pr-10136.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|
This was referenced Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Resolves
This PR is related to #10135, better to merge it afterwards.
LibreOffice and other cross-platform editors do not implement NSFilePresenter, so they get no path change notification when a parent folder is renamed. They keep using the old path while the parent folder was renamed and the user is editing a file. So the editor's save creates a brand-new folder on the server at the old name, uploads the file there, and the user silently ends up with both 2026/Spreadsheet.xlsx (stale copy) and 2026-renamed/Spreadsheet.xlsx (real file) on the server.
Summary
Refuse folder creation at a recently renamed path. A 60-second TTL cache records the old path when a directory is renamed. If a createItem arrives for a cached path the extension returns .cannotSynchronize instead of issuing a server MKCOL.
Steps to test it
✅ Before fix: a duplicate folder with the old name appears on the server.
✅ After fix: no duplicate folder is created. LibreOffice may show a save error (expected — the old path is gone).
✅ Only FolderA-renamed/Spreadsheet.xlsx exists on the server.
✅ Second save succeeds normally (TTL has cleared or the path is now correct).
Checklist
AI (if applicable)