feat: scan exports replace existing DB entries instead of accumulating
When starting a scan export batch, delete old scan_export entries for the same file+profile before writing new ones. Logs a warning when replacing. Prevents stale entry buildup from repeated scan exports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
@@ -418,6 +418,21 @@ class ProcessedDB:
|
|||||||
pass
|
pass
|
||||||
return max_n
|
return max_n
|
||||||
|
|
||||||
|
def delete_scan_exports(self, filename: str, profile: str) -> int:
|
||||||
|
"""Delete all scan_export entries for *filename* in *profile*.
|
||||||
|
|
||||||
|
Returns the number of rows deleted.
|
||||||
|
"""
|
||||||
|
if not self._enabled:
|
||||||
|
return 0
|
||||||
|
cur = self._con.execute(
|
||||||
|
"DELETE FROM processed"
|
||||||
|
" WHERE filename = ? AND profile = ? AND scan_export = 1",
|
||||||
|
(filename, profile),
|
||||||
|
)
|
||||||
|
self._con.commit()
|
||||||
|
return cur.rowcount
|
||||||
|
|
||||||
def get_vid_folder(self, filename: str, profile: str,
|
def get_vid_folder(self, filename: str, profile: str,
|
||||||
export_folder: str) -> str:
|
export_folder: str) -> str:
|
||||||
"""Return the vid_NNN folder name for a source video.
|
"""Return the vid_NNN folder name for a source video.
|
||||||
|
|||||||
@@ -4666,6 +4666,13 @@ class MainWindow(QMainWindow):
|
|||||||
self._auto_export_no_markers = batch["is_scan"]
|
self._auto_export_no_markers = batch["is_scan"]
|
||||||
self._export_batch_file = batch["file_path"]
|
self._export_batch_file = batch["file_path"]
|
||||||
|
|
||||||
|
# Replace old scan export entries for this video
|
||||||
|
if batch["is_scan"]:
|
||||||
|
fname = os.path.basename(batch["file_path"])
|
||||||
|
n_old = self._db.delete_scan_exports(fname, batch["profile"])
|
||||||
|
if n_old:
|
||||||
|
_log(f"Replacing {n_old} old scan export entries for {fname}")
|
||||||
|
|
||||||
n_queued = len(self._export_queue)
|
n_queued = len(self._export_queue)
|
||||||
q_msg = f" ({n_queued} queued)" if n_queued else ""
|
q_msg = f" ({n_queued} queued)" if n_queued else ""
|
||||||
self._show_status(f"Auto: exporting {len(batch['jobs'])} clips...{q_msg}")
|
self._show_status(f"Auto: exporting {len(batch['jobs'])} clips...{q_msg}")
|
||||||
|
|||||||
Reference in New Issue
Block a user