From 89e15dd023aee82190bacaadc337c282b91f5357 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 14 Nov 2023 15:33:32 +0100 Subject: [PATCH] Reimplemented by an accident deleted function --- main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index cbd44fb..a0a89e7 100644 --- a/main.py +++ b/main.py @@ -38,7 +38,19 @@ def find_duplicates(directories, file_type): return {file_hash: paths for file_hash, paths in hashes.items() if len(paths) > 1} - +def handle_file_modification(original_file, duplicate_file, modification): + if modification == 'delete': + print(f"Deleting {duplicate_file}") + os.remove(duplicate_file) + elif modification == 'hardlink': + os.remove(duplicate_file) + os.link(original_file, duplicate_file) + print(f"Replaced {duplicate_file} with a hardlink to {original_file}") + elif modification == 'symlink': + os.remove(duplicate_file) + os.symlink(original_file, duplicate_file) + print(f"Replaced {duplicate_file} with a symlink to {original_file}") + def handle_modification(files, modification, mode, apply_to): original_file = next((f for f in files if not f.startswith(tuple(apply_to))), files[0]) for duplicate_file in files: