fix(review): harden write-back, confirmation gate, and edge cases
- write-back: call upsert_tag inside _apply_tag's try so a tag-create failure is caught per-asset and apply_all no longer aborts mid-batch (was P1) - write-back: surface _pipeline/processed write failures in the result instead of discarding them (was reported as success) - ui: add title to the high confidence badge so approve-high-confidence's pre-action count is non-zero; confirm() before single-cluster apply - core: Store context manager; close DB connection even if a route raises; guard split_cluster against a first-member boundary (empty cluster); add writeback_log lookup index - ingest: split thumbnail download/write error handling and clean up the .tmp file on a write failure - tests: upsert/processed write-failure regression tests + split-guard test
This commit is contained in:
@@ -67,6 +67,8 @@ CREATE TABLE IF NOT EXISTS writeback_log (
|
||||
CREATE INDEX IF NOT EXISTS idx_assets_taken_at ON assets(taken_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_members_cluster ON cluster_members(cluster_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_members_asset ON cluster_members(immich_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_writeback_lookup
|
||||
ON writeback_log(immich_id, action, tag, result);
|
||||
"""
|
||||
|
||||
|
||||
@@ -109,6 +111,12 @@ class Store:
|
||||
self._conn.close()
|
||||
self._conn = None
|
||||
|
||||
def __enter__(self) -> "Store":
|
||||
return self
|
||||
|
||||
def __exit__(self, *exc) -> None:
|
||||
self.close()
|
||||
|
||||
def upsert_asset(self, a: Asset) -> None:
|
||||
has_gps = 1 if (a.gps_lat is not None and a.gps_lon is not None) else 0
|
||||
self.conn.execute(
|
||||
@@ -284,6 +292,10 @@ class Store:
|
||||
if boundary_immich_id not in ids:
|
||||
raise ValueError(f"boundary {boundary_immich_id!r} not in cluster")
|
||||
idx = ids.index(boundary_immich_id)
|
||||
if idx == 0:
|
||||
raise ValueError(
|
||||
f"boundary {boundary_immich_id!r} is the first member; "
|
||||
"split would leave an empty cluster")
|
||||
base = self.get_cluster(cluster_id)
|
||||
left, right = pairs[:idx], pairs[idx:]
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
{% elif confidence < 0.75 %}
|
||||
<span class="badge badge-sm badge-info">med</span>
|
||||
{% else %}
|
||||
<span class="badge badge-sm badge-success">high</span>
|
||||
<span class="badge badge-sm badge-success" title="high-confidence">high</span>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user