Skip to content

Commit

Permalink
Log missing files to export database, #1311
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Dec 5, 2023
1 parent cb9c36d commit 3ec07c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions osxphotos/export_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,11 +1399,11 @@ def _error(self) -> dict[str, Any] | None:

def _error_setter(self, value: dict[str, str] | None):
"""Set error value"""
value = value or {}
value = value or None
conn = self.connection
c = conn.cursor()
# use default=str because some of the values are Path objects
error = json.dumps(value, default=str)
error = json.dumps(value, default=str) if value else None
c.execute(
"UPDATE export_data SET error = ? WHERE filepath_normalized = ?;",
(error, self._filepath_normalized),
Expand Down
10 changes: 10 additions & 0 deletions osxphotos/photoexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@ def export(
sidecar_writer = SidecarWriter(self.photo)
all_results += sidecar_writer.write_sidecar_files(dest=dest, options=options)

# update export database for any missing files
for missing_file in all_results.missing:
with options.export_db.create_or_get_file_record(
missing_file, self.photo.uuid
) as rec:
rec.error = {"missing": True}
rec.export_options = options.bit_flags

return all_results

def _init_temp_dir(self, options: ExportOptions):
Expand Down Expand Up @@ -1023,6 +1031,8 @@ def _export_photo(
"exiftool_error": exif_results.exiftool_error,
"exiftool_warning": exif_results.exiftool_warning,
}
else:
rec.error = None

# clean up lock file
unlock_filename(dest_str)
Expand Down

0 comments on commit 3ec07c5

Please sign in to comment.