You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unlink / trash restore: moving a Windows junction across volumes falls back to a symlink #420
Follow-up to #419 (and the follow_source_links work in #274 / #417). Found during code review of the link / unlink branch; not a Windows runtime result yet, traced from source.
Problem
skillshare link creates a junction on Windows (mklink /J, internal/sync/symlink_windows.go) precisely so that no Developer Mode or elevation is needed. skillshare unlink and the dashboard DELETE /api/source-links/{name} then move that entry to the trash through trash.MoveToTrash (internal/sourcelink/sourcelink.go, Remove).
When the skills source and the trash directory live on different volumes (for example source on D: and the global trash under %LOCALAPPDATA% on C:), os.Rename fails with a cross-device error and moveLink in internal/trash/trash.go falls back to os.Symlink(target, dst) followed by os.Remove(src). That fallback recreates the junction as a directory symlink, which is exactly the privileged operation the junction avoided:
without Developer Mode / admin, unlink fails with a privilege error after link succeeded;
the same seam is hit on trash restore of a trashed link when the move goes back across volumes.
The symlink fallback is an existing trash behaviour; link / unlink just made it reachable for junctions.
Expected
Relocating a link across volumes keeps its kind: a junction is recreated with mklink /J (or the existing junction helper), a symlink with os.Symlink. If recreating a junction is impossible, the error should say so and leave the original link in place.
Where
internal/trash/trash.gomoveLink (symlink fallback after cross-device rename)
internal/sync/symlink_windows.go junction creation helper to reuse
Acceptance
Windows test (can be a windows-only unit test with a temp junction) that moves a junction to a trash directory on another volume and back, and asserts the entry is still a junction with the same target.
unlink and trash restore of a junction never require elevation.
Activity
fix(utils): quote junction paths passed to cmd.exe
fix(utils): create junctions through the reparse-point API
test(sourcefs): allow the raw writes in CreateJunction
fix(utils): accept extended-length paths as junction targets
fix(utils): detect junctions under GODEBUG=winsymlink=0
fix(utils): refuse a network path as a junction target
fix(trash): keep junctions as junctions when moving across volumes