Skip to content

fix(file-provider): prevent duplicate folder when editor saves to renamed path.#10136

Closed
camilasan wants to merge 2 commits into
masterfrom
bugfix/fpext-prevent-duplicate-folder
Closed

fix(file-provider): prevent duplicate folder when editor saves to renamed path.#10136
camilasan wants to merge 2 commits into
masterfrom
bugfix/fpext-prevent-duplicate-folder

Conversation

@camilasan

@camilasan camilasan commented Jun 9, 2026

Copy link
Copy Markdown
Member

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

  1. Open Spreadsheet.xlsx from a folder in Finder using LibreOffice.
  2. While the file is open, rename the parent folder from the web UI or another client.
  3. Wait for the client to sync the rename (the folder name in Finder should update).
  4. Without closing LibreOffice, save the file.
    ✅ 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.
  5. Close and reopen the file from the renamed folder location and save again.
    ✅ Second save succeeds normally (TTL has cleared or the path is now correct).

Checklist

AI (if applicable)

camilasan added 2 commits June 9, 2026 15:41
…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>
@camilasan

Copy link
Copy Markdown
Member Author

/backport to stable-33.0

@camilasan

Copy link
Copy Markdown
Member Author

/backport to stable-4.0

@camilasan camilasan added this to the 33.0.6 milestone Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Artifact containing the AppImage: nextcloud-appimage-pr-10136.zip

Digest: sha256:fb8de0749ad1f4d9dfc25c3807574998c15bd73c6ffe6886d239ad22f35f37a6

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.

@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

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.

1 participant