mirror of
https://github.com/kevinveenbirkenbach/duplicate-file-handler.git
synced 2024-11-22 05:51:03 +01:00
Solved symlink bug
This commit is contained in:
parent
f5c7a945c5
commit
ce5db7c6da
8
main.py
8
main.py
@ -13,13 +13,15 @@ def md5sum(filename):
|
||||
def find_duplicates(directories):
|
||||
hashes = defaultdict(list)
|
||||
for directory in directories:
|
||||
for root, dirs, files in os.walk(directory):
|
||||
for root, dirs, files in os.walk(directory, followlinks=False):
|
||||
for filename in files:
|
||||
path = os.path.join(root, filename)
|
||||
file_hash = md5sum(path)
|
||||
hashes[file_hash].append(path)
|
||||
if not os.path.islink(path):
|
||||
file_hash = md5sum(path)
|
||||
hashes[file_hash].append(path)
|
||||
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}")
|
||||
|
Loading…
Reference in New Issue
Block a user