feat: auto-use cached HQ video file without upgrade prompt

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-22 14:36:33 -04:00
parent 90f598050c
commit 8bd2b34103

View File

@@ -262,6 +262,22 @@ export async function beginDownload() {
session.processingStep = 'downloading';
// --- Check export (HQ) cache first ---
const exportCached = await checkCachedDownload(session.title, 'export').catch(() => null);
if (exportCached) {
// HQ file already on disk — use it directly, skip preview entirely
session.exportFilePath = exportCached;
session.exportProgress = 1.0;
session.exportStatus = 'complete';
session.previewFilePath = exportCached;
session.previewProgress = 1.0;
session.previewStatus = 'complete';
session.activeVideoPath = exportCached;
// No upgrade toast — we're already at best quality
triggerPostDownloadProcessing(exportCached);
return;
}
// --- Preview download (low-res, fast) ---
const previewCached = await checkCachedDownload(session.title, 'preview').catch(() => null);
if (previewCached) {
@@ -305,45 +321,35 @@ export async function beginDownload() {
}
// --- Export download (best quality, background) ---
const exportCached = await checkCachedDownload(session.title, 'export').catch(() => null);
if (exportCached) {
session.exportFilePath = exportCached;
session.exportProgress = 1.0;
session.exportStatus = 'complete';
if ((session.processingStep as ProcessingStep) === 'done') {
session.showUpgradeToast = true;
}
} else {
session.exportStatus = 'downloading';
session.exportProgress = 0;
session.exportFilePath = null;
// Only start if not already cached (we handled cached case above with early return)
session.exportStatus = 'downloading';
session.exportProgress = 0;
session.exportFilePath = null;
// Fire-and-forget — runs in background
runDownload(
session.url,
EXPORT_FORMAT,
'export',
(pct) => { session.exportProgress = pct; },
(path) => { session.exportFilePath = path; },
(success, path) => {
if (success) {
session.exportProgress = 1.0;
session.exportFilePath = path;
session.exportStatus = 'complete';
if ((session.processingStep as ProcessingStep) === 'done') {
session.showUpgradeToast = true;
}
} else {
session.exportStatus = 'failed';
runDownload(
session.url,
EXPORT_FORMAT,
'export',
(pct) => { session.exportProgress = pct; },
(path) => { session.exportFilePath = path; },
(success, path) => {
if (success) {
session.exportProgress = 1.0;
session.exportFilePath = path;
session.exportStatus = 'complete';
if ((session.processingStep as ProcessingStep) === 'done') {
session.showUpgradeToast = true;
}
},
(message) => {
} else {
session.exportStatus = 'failed';
console.error('Export download error:', message);
}
).catch((e) => {
},
(message) => {
session.exportStatus = 'failed';
console.error('Export download failed:', e);
});
}
console.error('Export download error:', message);
}
).catch((e) => {
session.exportStatus = 'failed';
console.error('Export download failed:', e);
});
}