mirror of
https://github.com/kevinveenbirkenbach/duplicate-file-handler.git
synced 2024-11-14 18:11: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):
|
def find_duplicates(directories):
|
||||||
hashes = defaultdict(list)
|
hashes = defaultdict(list)
|
||||||
for directory in directories:
|
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:
|
for filename in files:
|
||||||
path = os.path.join(root, filename)
|
path = os.path.join(root, filename)
|
||||||
file_hash = md5sum(path)
|
if not os.path.islink(path):
|
||||||
hashes[file_hash].append(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}
|
return {file_hash: paths for file_hash, paths in hashes.items() if len(paths) > 1}
|
||||||
|
|
||||||
|
|
||||||
def handle_file_modification(original_file, duplicate_file, modification):
|
def handle_file_modification(original_file, duplicate_file, modification):
|
||||||
if modification == 'delete':
|
if modification == 'delete':
|
||||||
print(f"Deleting {duplicate_file}")
|
print(f"Deleting {duplicate_file}")
|
||||||
|
Loading…
Reference in New Issue
Block a user