Reimplemented by an accident deleted function

This commit is contained in:
Kevin Veen-Birkenbach 2023-11-14 15:33:32 +01:00
parent e31ee231fa
commit 89e15dd023
1 changed files with 13 additions and 1 deletions

14
main.py
View File

@ -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: