Skip to content

[stable-34.0] fix(libsync): folder move or rename data loss. - #10218

Merged
mgallien merged 8 commits into
stable-34.0from
backport/9998/stable-34.0
Jun 22, 2026
Merged

[stable-34.0] fix(libsync): folder move or rename data loss.#10218
mgallien merged 8 commits into
stable-34.0from
backport/9998/stable-34.0

Conversation

@backportbot

@backportbot backportbot Bot commented Jun 22, 2026

Copy link
Copy Markdown

Backport of PR #9998

camilasan and others added 8 commits June 22, 2026 09:14
- startsWith(deletedDir) without a trailing slash would match sibling
directories sharing a common prefix (e.g. "A/B" matching "A/BC"),
causing their journal records to be skipped in the failure-cleanup
loop. Append '/' before the comparison.
- Add test to cover removeRecursively sibling prefix guard.
- Add isPathInsideDeletedDir as an inline header helper and a unit test
verifying a sibling such as "A/BC" is not treated as a child of "A/B",
guarding the journal cleanup after a failed local remove. Use qWarning
instead of the deprecated QWARN in the testMovedWithError data rows.

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Camila Ayres <[email protected]>
WebDAV lock tokens are bound to the URL they were issued for. When a
parent directory is renamed, PropagateLocalRename and
PropagateRemoteMove both copy child journal records to the new path
while preserving the old token. Subsequent uploads send the stale
token and receive 412/423 from the server.

Clear the token from the journal on either status code so the next
sync retries without it. Schedule rediscovery on 412 since the server
state is uncertain.

Force remote rediscovery on both 412 and 423 upload errors so the lock
state cleared from the journal is refreshed from the server, not only the
bad etag on 412. Strengthen the 412 test to assert the parent folder etag
is invalidated.

Add a matching Q_OS_WIN guard in testLockedStateClearedOnClientInitiatedRename
to clear the ACL before the local directory rename, which Windows requires
when files inside have an ACL-based read-only restriction.

Assisted-by: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Camila Ayres <[email protected]>
When a remote directory move is finalized, iterate all children
recorded in the sync journal and rewrite their paths to reflect the
new location, clearing stale lock state. Without this, children
retained the old path in the database and could be treated as new
uploads or silently lost on the next sync cycle.

Assisted-by: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Camila Ayres <[email protected]>
Signed-off-by: Camila Ayres <[email protected]>
Signed-off-by: Camila Ayres <[email protected]>
we might delete local client DB records when tracking server rename
leading to loose of state by the client that will trigger wrong sync
decisions

Signed-off-by: Matthieu Gallien <[email protected]>
@mgallien
mgallien enabled auto-merge June 22, 2026 09:17
@github-actions

Copy link
Copy Markdown
Contributor

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

Digest: sha256:10270e59f2ab46a23e7b866d5b54ec5ee5209fcd132af8868a1075749dc9d203

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.

@mgallien
mgallien merged commit 8d851ae into stable-34.0 Jun 22, 2026
17 of 18 checks passed
@mgallien
mgallien deleted the backport/9998/stable-34.0 branch June 22, 2026 09:32
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants