Tools: add Deep Scan option to the Database Updater

The Tools-page Database Updater dropdown only offered Incremental and
Full Refresh, even though the backend (/api/database/update with
deep_scan) and the dashboard Deep Scan button already supported a deep
scan. Wire the missing option into the Tools UI:

- Add a "Deep Scan" option to the #db-refresh-type dropdown.
- handleDbUpdateButtonClick now sends { deep_scan: true } for that
  option (deep scan takes precedence server-side) and confirms first,
  since deep scan removes stale entries — mirroring the dashboard flow.

Frontend-only; the progress/status handler already drives the bar from
the backend phase ("Deep scan: ...") and the help/docs copy already
described all three modes.
This commit is contained in:
BoulderBadgeDad 2026-05-29 10:47:02 -07:00
parent 54d0fed345
commit 21426af7fe
2 changed files with 11 additions and 2 deletions

View file

@ -6447,6 +6447,7 @@
<select id="db-refresh-type">
<option value="incremental">Incremental Update</option>
<option value="full">Full Refresh</option>
<option value="deep">Deep Scan</option>
</select>
<button id="db-update-button">Update Database</button>
</div>

View file

@ -4022,12 +4022,18 @@ async function handleDbUpdateButtonClick() {
if (currentAction === 'Update Database') {
const refreshSelect = document.getElementById('db-refresh-type');
const isFullRefresh = refreshSelect.value === 'full';
const refreshType = refreshSelect.value;
const isFullRefresh = refreshType === 'full';
const isDeepScan = refreshType === 'deep';
if (isFullRefresh) {
// Replicates the QMessageBox confirmation from the GUI
const confirmed = await showConfirmDialog({ title: 'Full Refresh', message: 'This will clear and rebuild the database for the active server. It can take a long time.\n\nAre you sure you want to proceed?', confirmText: 'Proceed' });
if (!confirmed) return;
} else if (isDeepScan) {
// Deep scan removes stale entries — confirm like the dashboard deep scan does.
const confirmed = await showConfirmDialog({ title: 'Deep Scan', message: 'A deep scan re-checks every track in your media server library against the database.\n\n• Adds any new tracks that were missed\n• Removes tracks no longer on your server\n• Preserves all existing metadata and enrichment data\n\nThis may take a while for large libraries. Proceed?', confirmText: 'Proceed' });
if (!confirmed) return;
}
try {
@ -4036,7 +4042,9 @@ async function handleDbUpdateButtonClick() {
const response = await fetch('/api/database/update', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ full_refresh: isFullRefresh })
// Deep scan and full refresh use distinct backend flags; deep
// scan takes precedence server-side, so send only its flag.
body: JSON.stringify(isDeepScan ? { deep_scan: true } : { full_refresh: isFullRefresh })
});
if (response.ok) {