Compare commits

...

2 Commits

Author SHA1 Message Date
df5fc37419
Don't generate no-ops 2025-06-01 14:46:49 +02:00
b5649a349b
Skip no-ops when moving 2025-06-01 14:45:00 +02:00
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,10 @@ class MoveInstruction(Instruction):
new_path: Path
def __call__(self) -> None:
if self.old_path == self.new_path:
# No-op
return
if self.new_path.exists():
raise FileExistsError("New path already exists, not moving anything")

View File

@ -62,6 +62,12 @@ def move(songs: Sequence[Song], base_dir: Path) -> Sequence[MoveInstruction]:
variant += 1
song_dir_strs_lower.add(str(canonical_song_dir).lower())
if song_dir == canonical_song_dir:
# After finding a free variant index, we arrived at the index we already had previously, this means
# we do not need to generate a move instruction
continue
move_instructions.append(
MoveInstruction(absolute_song_dir, base_dir / canonical_song_dir)
)