Repository navigation
fix(sync): prune only links skillshare created - #315
Merged
Merged
Conversation
Merge-mode prune removed any target entry that was a symlink or junction resolving under the skills source, without checking whether skillshare had created it. Links made by hand or by another tool were therefore deleted by name, silently and outside trash, so they were not recoverable through restore. Ask the manifest, which the directory branch of this same function and all of copy-mode pruning already treat as the ownership record: a live link into the source is pruned when it is tracked there or when --force is set, and is kept and reported as a local entry otherwise. Broken links into the source and the force escape hatch behave exactly as before.
Owner
|
Thanks for the thorough report and the tight fix — the provenance check matches how the directory branch and copy-mode pruning already decide ownership. Verified locally in the devcontainer on
Two small follow-ups I'll handle on our side, so no changes needed here:
The agent and extras cases you listed are worth their own issue. Merging now. |
runkids
approved these changes
Oct 1, 2026
runkids
left a comment
Owner
There was a problem hiding this comment.
Reviewed and verified locally; approving.
runkids
added a commit
that referenced
this pull request
Oct 1, 2026
Since #315, a live link into the source is pruned only when the manifest tracks it. The ManagedOnly comments still said any link into the source counted as skillshare's, which no longer matches what the leftover-dir cleanup removes.
runkids
added a commit
that referenced
this pull request
Oct 1, 2026
Merge-mode pruning for agents and extras removed any link whose name was not expected, so links a user made to agent or extra files outside the source were deleted on the next sync or `extras --remove-target --prune`. Agents and extras do not record their links in a manifest, so the #315 provenance check cannot be reused. Prune now removes a link only when it is broken or resolves inside the source. Relative links are resolved from the real parent directory, matching how createLink writes them, so orphans under a symlinked target directory are still found.
4 of 7 tasks
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.
What
merge-mode prune stops deleting links it never created.PruneOrphanLinksWithSkillsremoved any target entry that was a symlink/junction resolvingunder the skills source and was not in the current filter resolution, without asking whether
skillshare had created it. Provenance is already recorded —
SyncTargetMergeWithSkillswritesmanifest.Managed[name] = "symlink"for every link it creates — and the directory branch ofthis same function, and all of copy-mode pruning, already consult the manifest. This applies
the same rule to links:
local--forceA kept link is appended to
PruneResult.LocalDirs, whichsync_parallel.goalready folds intothe
merged (N linked, M local, …)line, so no output plumbing changes.Reproduction
Reported in #314 with a full transcript. Short version, released 0.22.0 binary on Windows,
isolated config, one source skill
handmadeoutside the target'sinclude, linked in by handwith
mklink /J:Reproduced on a real 12-target / 663-link pool where one unqualified
syncremoved 140hand-made links; content survived in the source, the wiring did not, and it was not in
trash.Tests
internal/sync/merge_test.goaddsTestPruneOrphanLinks_KeepsUnmanagedLiveLinkToSource, whichfails on unpatched
main(bcb8c6c7) at four assertions — link kept,0 removed,1 local, andthe follow-up
forceprune finding nothing left to remove — and passes with the change. The sametest then prunes with
forceand expectshandmadeto go, so the escape hatch is pinned too.No existing test needed editing — in particular
TestPruneOrphanLinks_RemovesOrphans(brokenlink into source) and
TestPruneOrphanLinks_RemovesExcluded(manifest-tracked live link, nowfiltered out) still pass unchanged, which is the guard that this narrows the rule rather than
disabling it.
Verified in a Linux environment (WSL2 Ubuntu, Go 1.25.6, devcontainer not used), on a tree reset
to current
mainbcb8c6c781d86c656f1fb7fdc95ca73ebbaecb7c:git apply --checkclean;gofmt -lclean on both changed Go files;go vet ./internal/sync/cleango test -run TestPruneOrphanLinks -v ./internal/sync/→ 12 PASS, incl. the new onego test ./internal/...→ 27 packages ok, 0 failuresgo test -run 'Sync|Prune' ./cmd/skillshare/→ ok, identically with and without the changeOne gap in my local evidence: the full
./cmd/skillsharepackage does not run to completion inmy WSL environment — I watched it exceed both its own
-timeout 90sand a 150 s wall clock onunpatched
main, so it is an environment limit rather than a consequence of this change, butit does mean I cannot claim a clean sweep for that one package. The devcontainer is the authority
there; I will fix anything CI surfaces.
Docs
Two English lines that were ambiguous about who created the link, updated to match:
website/docs/reference/targets/configuration.md— the "Existing target entries when filterschange" table now distinguishes a link skillshare created from a live link it never tracked.
The
jatranslation of this row already reads "Source-managed symlinks/junctions", which isthe behaviour implemented here.
website/docs/reference/commands/sync.md— same distinction in "What gets removed whenfilters change".
The same table exists under
website/i18n/{ja,ko,zh-Hans,zh-Hant}. Say the word and I willupdate those four in this PR, or leave them to your normal translation flow — I did not want to
guess at wording I am not qualified to write.
Deliberately out of scope
Two more prunes share the root cause and are not touched here:
PruneOrphanAgentLinks(internal/sync/agent_sync.go, removes any unexpected.mdlink withneither a source-prefix nor a provenance test) and
PruneExtraTarget→pruneExtraOrphans(
internal/sync/extras.go, empty managed set + merge mode deletes target symlinks). Worth afollow-up once the skills-side rule is agreed; I kept this to one concern.
Closes #314