Skip to content

fix(file-provider): prevent data loss when parent folder moves during sync.#10134

Draft
camilasan wants to merge 2 commits into
masterfrom
bugfix/fpext-prevent-data-loss-on-move
Draft

fix(file-provider): prevent data loss when parent folder moves during sync.#10134
camilasan wants to merge 2 commits into
masterfrom
bugfix/fpext-prevent-data-loss-on-move

Conversation

@camilasan

@camilasan camilasan commented Jun 9, 2026

Copy link
Copy Markdown
Member

Resolves

This PR is related to #10130, better to merge it afterwards.

Moving a folder on another client could silently wipe its contents from the device. An in-flight upload through a deleted parent would lose data permanently. Reporting children before the parent causes macOS to create a duplicate folder.

Summary

Items found at a new location are not deleted; pending uploads and open lock files are protected — the enumerator now waits until the full sync pass completes before deciding what is deleted, using a survivingOcIds set to spare anything found at a new path. Items mid-upload and local-origin lock files are excluded from deletion even when their parent is removed. Items are also sorted parent-before-child before being reported to macOS to prevent duplicate folders caused by ordering.

Steps to test it

Scenario A Move:

  1. Create doc.txt in FolderA. Let it sync.
  2. Move doc.txt into FolderB from the web UI.
  3. Wait for next sync cycle.
    ✅ doc.txt must appear inside FolderB in Finder.
    ✅ doc.txt must not appear as deleted anywhere.

Scenario B — Upload protection:

  1. Start uploading a large file (500 MB+) into FolderA.
  2. While uploading, delete FolderA from the web UI.
    ✅ The upload must complete and the file must appear on the server.
    ✅ The uploading file must not be silently lost.

Scenario C — No duplicate folder on rename:

  1. Create FolderA with a file inside. Let it sync and open the file in an editor.
  2. Rename FolderA → FolderA-renamed from the web UI.
    ✅ Only FolderA-renamed must appear in Finder — no duplicate FolderA.

Checklist

AI (if applicable)

camilasan added 2 commits June 9, 2026 14:57
… sync.

When a parent directory returns 404, children are no longer eagerly
marked deleted — they may have moved with the parent. The
deconfliction pass now includes newly discovered items, and items
with pending uploads are protected from deletion in both the
enumerator and recursive directory delete paths.

Assisted-by: Claude:claude-sonnet-4-5
Signed-off-by: Camila Ayres <hello@camilasan.com>
Assisted-by: Claude:claude-sonnet-4-5
@camilasan camilasan changed the title Bugfix/fpext prevent data loss on move fix(file-provider): prevent data loss when parent folder moves during sync. Jun 9, 2026
@camilasan

Copy link
Copy Markdown
Member Author

/backport to stable-33.0

@camilasan

Copy link
Copy Markdown
Member Author

/backport to stable-4.0

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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

Digest: sha256:cfd96041e158994d8639f4047ab0f1010f529796c735e496fffdd75258981460

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