Update engine.py

This commit is contained in:
2026-01-17 14:17:04 +01:00
parent 5c788398a6
commit 17d8a3b95d

View File

@@ -70,12 +70,27 @@ class SorterEngine:
return t_dst, c_dst return t_dst, c_dst
@staticmethod @staticmethod
def move_to_unused_synced(t_p, c_p, t_root, c_root): def harmonize_names(t_p, c_p):
"""Moves both to 'unused' subfolders with synced names.""" """Renames the control file to match the target filename exactly."""
t_name = os.path.basename(t_p) t_name = os.path.basename(t_p)
t_un, c_un = os.path.join(t_root, "unused", t_name), os.path.join(c_root, "unused", t_name) c_dir = os.path.dirname(c_p)
new_c_p = os.path.join(c_dir, t_name)
if c_p != new_c_p:
os.rename(c_p, new_c_p)
return new_c_p
return c_p
@staticmethod
def move_to_unused_synced(t_p, c_p, t_root, c_root):
"""Moves both to 'unused' subfolders and ensures names match."""
t_name = os.path.basename(t_p)
t_un = os.path.join(t_root, "unused", t_name)
c_un = os.path.join(c_root, "unused", t_name) # Forced harmonization
os.makedirs(os.path.dirname(t_un), exist_ok=True) os.makedirs(os.path.dirname(t_un), exist_ok=True)
os.makedirs(os.path.dirname(c_un), exist_ok=True) os.makedirs(os.path.dirname(c_un), exist_ok=True)
shutil.move(t_p, t_un) shutil.move(t_p, t_un)
shutil.move(c_p, c_un) shutil.move(c_p, c_un)
return t_un, c_un return t_un, c_un