]> git.treefish.org Git - photosort.git/commitdiff
do not look for alternative file in source dir
authorAlexander Schmidt <alex@treefish.org>
Fri, 16 Oct 2020 11:20:45 +0000 (13:20 +0200)
committerAlexander Schmidt <alex@treefish.org>
Fri, 16 Oct 2020 11:20:45 +0000 (13:20 +0200)
src/misc.py
src/photosort.py

index 4cbbf74e9f2787af3a40d09cd41593bfe8900080..7ef46f36ffd5313ed1451c1add276e2024c7f7b6 100644 (file)
@@ -12,8 +12,10 @@ def walk_media_files(dir_path):
 def extract_timestamp(file_path):
     return os.path.getmtime(file_path)
 
-def find_file(dir_path, file_name, file_size):
+def find_file(dir_path, file_name, file_size, exclude_dir):
     for root, dirs, files in os.walk(dir_path):
+        if root == exclude_dir:
+            continue
         for f in files:
             if f == file_name:
                 full_path = os.path.join(root, f)
index 4c4149ef81def8f810b93aec124ad4aa09778a95..3124eaec4e76f347a376ac78d5408f8239986b46 100755 (executable)
@@ -33,7 +33,8 @@ for src_file_name, src_file_path in misc.walk_media_files(args.SOURCE_DIR):
     if not os.path.exists(dst_file_path):
         alt_dst_dir = misc.find_file(args.DEST_DIR,
                                      src_file_name,
-                                     os.path.getsize(src_file_path))
+                                     os.path.getsize(src_file_path),
+                                     exclude_dir=args.SOURCE_DIR)
         if alt_dst_dir:
             dst_dir = alt_dst_dir
             dst_file_path = os.path.join(dst_dir, src_file_name)