Skip to content

unlink / trash restore: moving a Windows junction across volumes falls back to a symlink #420

Closed

Description

@runkids

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.go moveLink (symlink fallback after cross-device rename)
  • internal/sourcelink/sourcelink.go Remove → trash.MoveToTrash
  • internal/trash/trash.go restore cross-device fallback
  • 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.

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions