Skip to content

Commit

Permalink
updates metadata store for already downloaded files not in the store.
Browse files Browse the repository at this point in the history
Handling the edge case where you have downloaded files without the metadata store enabled, and then turn it on afterwards.
  • Loading branch information
beaufour committed Sep 9, 2023
1 parent 44d7eac commit 50c6784
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions flickr_download/flick_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,22 @@ def do_download_photo(
# TODO: Ideally we should check for file size / md5 here
# to handle failed downloads.
logging.info("Skipping %s, as it exists already", fname)
return

logging.info("Saving: %s (%s)", fname, get_photo_page(photo))
if skip_download:
return
else:
logging.info("Saving: %s (%s)", fname, get_photo_page(photo))
if skip_download:
return

try:
photo.save(fname, size_label)
except IOError as ex:
logging.error("IO error saving photo: %s", ex)
return
except FlickrError as ex:
logging.error("Flickr error saving photo: %s", ex)
return
try:
photo.save(fname, size_label)
except IOError as ex:
logging.error("IO error saving photo: %s", ex)
return
except FlickrError as ex:
logging.error("Flickr error saving photo: %s", ex)
return

# Set file times to when the photo was taken
set_file_time(fname, photo["taken"])
# Set file times to when the photo was taken
set_file_time(fname, photo["taken"])

if metadata_db:
metadata_db.execute(
Expand Down

0 comments on commit 50c6784

Please sign in to comment.