Skip to content

Commit

Permalink
Improve duplicates detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed May 2, 2024
1 parent b146600 commit be3798f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mmdiary/utils/datelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def scan(self):
al = medialib.MediaLib(path)
for af in al.get_processed():
fname = af.name()
if self.check_file(fname) is None:
if af.has_file() and self.check_file(fname) is None:
self.add_file(
get_date_from_timestring(af.json()["recordtime"]),
fname,
Expand Down
7 changes: 4 additions & 3 deletions src/mmdiary/utils/medialib.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ def __scan_files(self, inpath):
for fname in files:
base, ext = os.path.splitext(fname)
lext = ext.lower()
full_name = os.path.join(root, fname)
if lext in self.__supported_exts:
if base in res_files:
logging.error('duplicate %s in %s', base, root)
res_files[base] = os.path.join(root, fname)
logging.error('duplicate %s, %s', full_name, res_files[base])
res_files[base] = full_name
elif lext == JSON_EXT:
json_files[base] = os.path.join(root, fname)
json_files[base] = full_name

return res_files, json_files

Expand Down

0 comments on commit be3798f

Please sign in to comment.