Added --force-update, #621

This commit is contained in:
Rhet Turnbull
2022-02-12 21:01:16 -08:00
parent a2f329b8de
commit 30abdddaf3
15 changed files with 50 additions and 27 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.45.9"
__version__ = "0.45.10"

View File

@@ -3164,7 +3164,7 @@ def export_photo_to_directory(
)
if verbose:
if update:
if update or force_update:
for new in results.new:
verbose_(f"Exported new file {new}")
for updated in results.updated:

View File

@@ -1033,9 +1033,9 @@ class PhotoExporter:
# need to also check the photo's metadata to that in the database
# and if anything changed, we need to update the file
# ony the hex digest of the metadata is stored in the database
cmp_orig = hexdigest(
self.photo.json()
) == export_db.get_metadata_for_file(dest_str)
photo_digest = hexdigest(self.photo.json())
db_digest = export_db.get_metadata_for_file(dest_str)
cmp_orig = photo_digest == db_digest
sig_cmp = cmp_touch if options.touch_file else cmp_orig
@@ -1138,6 +1138,8 @@ class PhotoExporter:
) from e
json_info = self.photo.json()
# don't set the metadata digest if not force_update so that future use of force_update catches metadata change
metadata_digest = hexdigest(json_info) if options.force_update else None
export_db.set_data(
filename=dest_str,
uuid=self.photo.uuid,
@@ -1145,7 +1147,7 @@ class PhotoExporter:
converted_stat=converted_stat,
edited_stat=edited_stat,
info_json=json_info,
metadata=hexdigest(json_info),
metadata=metadata_digest,
)
return ExportResults(

View File

@@ -1729,6 +1729,9 @@ class PhotoInfo:
return o.isoformat()
dict_data = self.asdict()
for k, v in dict_data.items():
if v and isinstance(v, (list, tuple)) and not isinstance(v[0], dict):
dict_data[k] = sorted(v)
return json.dumps(dict_data, sort_keys=True, default=default)
def __eq__(self, other):

View File

@@ -211,10 +211,12 @@ class SearchInfo:
"""return list of text for a specified category ID"""
if self._db_searchinfo:
content = "normalized_string" if self._normalized else "content_string"
return [
rec[content]
for rec in self._db_searchinfo
if rec["category"] == category
]
return sorted(
[
rec[content]
for rec in self._db_searchinfo
if rec["category"] == category
]
)
else:
return []