Skip to content

v0.7.3 - Link Handling Modes

Latest

Choose a tag to compare

@djdarcy djdarcy released this 20 Dec 15:12
· 2 commits to main since this release
6efd8d0

--link-handling Flag for MOVE Operations (#48)

This release adds link handling modes to control behavior when MOVE encounters symlinks/junctions that would create cycles with the destination.

The Problem

After using preserve MOVE ... -L junction to relocate subdirectories, users couldn't move parent directories because the nested junctions pointed back to the destination:

# Step 1: Move subdirectory with junction
preserve MOVE "C:\cache\huggingface" --dst "E:\cache\huggingface" -L junction

# Step 2: Later, try to consolidate parent - BLOCKED!
preserve MOVE "C:\cache" --dst "E:\cache"
# Error: Cycle detected - nested junction points to destination

The Solution

New --link-handling MODE flag:

Mode Behavior
block (default) Block operation if cycle-creating links found
skip Skip links, move non-link content only
unlink Remove links pointing to destination after successful move
# Skip the problematic links, move everything else
preserve MOVE "C:\cache" --dst "E:\cache" --link-handling skip

# Consolidation mode - remove links after move
preserve MOVE "C:\cache" --dst "E:\cache" --link-handling unlink

Added

  • --link-handling CLI flag with block, skip, unlink modes
  • LinkHandlingMode enum with from_string() parser
  • LinkInfo dataclass for link analysis
  • analyze_link() and decide_link_action() functions
  • creates_cycle field in link report
  • 19 new unit tests (284 total)

Phase 2 (Future)

  • recreate mode: Copy links to destination with adjusted targets
  • ask mode: Interactive prompt for each link

See #48 for progress on Phase 2.

Related

  • #47 - Deep cycle detection (v0.7.2)
  • #49 - Performance: In-situ detection for large trees