fix: clear thumbnail cache and temp dirs on new session
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,10 +2,12 @@ import type { VideoMetadata } from '$lib/bindings/video';
|
||||
import { startDownload } from '$lib/bindings/video';
|
||||
import type { ThumbnailSpritesheet } from '$lib/bindings/mediaAnalysis';
|
||||
import {
|
||||
cleanupThumbnails,
|
||||
extractKeyframes,
|
||||
extractThumbnails,
|
||||
extractWaveform,
|
||||
} from '$lib/bindings/mediaAnalysis';
|
||||
import { clearThumbnailCache } from '$lib/timeline/thumbnailRenderer';
|
||||
|
||||
export type SessionStatus = 'idle' | 'resolving' | 'ready' | 'error';
|
||||
export type DownloadStatus = 'idle' | 'downloading' | 'complete' | 'failed';
|
||||
@@ -112,6 +114,10 @@ async function triggerPostDownloadProcessing(filePath: string) {
|
||||
export async function beginDownload() {
|
||||
if (!session.url) return;
|
||||
|
||||
const oldThumbnailDirs = [
|
||||
...new Set(session.thumbnailSpritesheets.map((sheet) => sheet.filePath)),
|
||||
];
|
||||
clearThumbnailCache();
|
||||
session.downloadStatus = 'downloading';
|
||||
session.downloadProgress = 0;
|
||||
session.localFilePath = null;
|
||||
@@ -119,6 +125,12 @@ export async function beginDownload() {
|
||||
session.waveformPeaks = [];
|
||||
session.thumbnailSpritesheets = [];
|
||||
|
||||
if (oldThumbnailDirs.length > 0) {
|
||||
void cleanupThumbnails(oldThumbnailDirs).catch((err) => {
|
||||
console.error('Thumbnail temp dir cleanup failed:', err);
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await startDownload(
|
||||
session.url,
|
||||
|
||||
Reference in New Issue
Block a user