feat(dz): add cache clearing and database reset functionality

Add ability to fully clear cached online library by deleting and recreating the database file.
Integrate new Clear Cache option in settings UI, which restarts the app after clearing.
Remove unused artist/album fields from cache and UI. Add process plugin for relaunch.
This commit is contained in:
2025-10-02 13:40:13 -04:00
parent d8456ce912
commit d774aba0d4
11 changed files with 143 additions and 61 deletions

View File

@@ -340,7 +340,6 @@
<tr>
<th>Playlist</th>
<th>Tracks</th>
<th>Creator</th>
</tr>
</thead>
<tbody>
@@ -351,7 +350,6 @@
>
<td>{playlist.title}</td>
<td>{playlist.nb_tracks}</td>
<td>{playlist.creator_name}</td>
</tr>
{/each}
</tbody>
@@ -403,7 +401,6 @@
<thead>
<tr>
<th>Artist</th>
<th>Albums</th>
</tr>
</thead>
<tbody>
@@ -413,7 +410,6 @@
onclick={() => handleItemClick(i)}
>
<td>{artist.name}</td>
<td>{artist.nb_album}</td>
</tr>
{/each}
</tbody>
@@ -433,7 +429,6 @@
<tr>
<th>Album</th>
<th>Artist</th>
<th>Tracks</th>
<th>Year</th>
</tr>
</thead>
@@ -445,7 +440,6 @@
>
<td>{album.title}</td>
<td>{album.artist_name}</td>
<td>{album.nb_tracks}</td>
<td>{album.release_date ? new Date(album.release_date).getFullYear() : '—'}</td>
</tr>
{/each}

View File

@@ -15,7 +15,9 @@
loadSettings
} from '$lib/stores/settings';
import { clearLibrary as clearLibraryDb } from '$lib/library/database';
import { clearDeezerCache } from '$lib/library/deezer-database';
import { open, confirm, message } from '@tauri-apps/plugin-dialog';
import { relaunch } from '@tauri-apps/plugin-process';
let currentMusicFolder = $state<string | null>(null);
let currentPlaylistsFolder = $state<string | null>(null);
@@ -100,6 +102,22 @@
}
}
}
async function clearDeezerDatabase() {
const confirmed = await confirm(
'This will clear all cached Deezer favorites data and restart the app. Continue?',
{ title: 'Clear Deezer Cache', kind: 'warning' }
);
if (confirmed) {
try {
await clearDeezerCache();
await relaunch();
} catch (error) {
await message('Error clearing Deezer cache: ' + (error as Error).message, { title: 'Error', kind: 'error' });
}
}
}
</script>
<div style="padding: 8px;">
@@ -292,6 +310,12 @@
<small class="help-text">This will delete all cached library data from the database. Your music files will not be affected.</small>
<button onclick={clearLibraryDatabase}>Clear Library Database</button>
</div>
<div class="field-row-stacked">
<div class="setting-heading">Clear Deezer Cache</div>
<small class="help-text">This will delete all cached Deezer favorites data. The next time you visit the Deezer page, it will refetch from the API.</small>
<button onclick={clearDeezerDatabase}>Clear Deezer Cache</button>
</div>
</section>
{/if}
</div>