Clean up converted upload sources

This commit is contained in:
mARTin-B78 2026-08-19 18:41:31 +02:00
parent e452b0f000
commit 25264517a9
5 changed files with 22 additions and 6 deletions

View File

@ -5,6 +5,11 @@ Follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) · versioned wi
--- ---
## [1.20.45] — 2026-08-19
### Fixed
- **Temporary upload sources are now removed after conversion.** Audio previews no longer leave the original uploaded file behind in the temporary directory alongside the registered WAV.
## [1.20.44] — 2026-08-19 ## [1.20.44] — 2026-08-19
### Fixed ### Fixed

View File

@ -1 +1 @@
1.20.44 1.20.45

View File

@ -149,12 +149,22 @@ async def upload(file: UploadFile = File(...)):
if suffix not in _UPLOAD_EXTS: if suffix not in _UPLOAD_EXTS:
raise HTTPException(400, "Unsupported audio/video file type") raise HTTPException(400, "Unsupported audio/video file type")
dest = TEMP_DIR / f"{uuid.uuid4().hex}{suffix}" dest = TEMP_DIR / f"{uuid.uuid4().hex}{suffix}"
with dest.open("wb") as f:
_copy_limited(file.file, f, _MAX_UPLOAD_BYTES)
try: try:
with dest.open("wb") as f:
_copy_limited(file.file, f, _MAX_UPLOAD_BYTES)
wav = _to_wav_24k(dest) wav = _to_wav_24k(dest)
except Exception as e: except Exception as e:
if isinstance(e, HTTPException):
raise
raise HTTPException(400, f"Audio conversion failed: {e}") raise HTTPException(400, f"Audio conversion failed: {e}")
finally:
# The converted WAV is registered below; the original upload is only
# an intermediate and must not accumulate in TEMP_DIR after every
# preview/upload operation.
try:
dest.unlink(missing_ok=True)
except Exception:
pass
fid = uuid.uuid4().hex fid = uuid.uuid4().hex
_registry_put(fid, wav) _registry_put(fid, wav)
return {"id": fid, "duration": _duration(wav), "filename": file.filename} return {"id": fid, "duration": _duration(wav), "filename": file.filename}

View File

@ -10,7 +10,7 @@
<meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="telephone=no">
<meta name="color-scheme" content="light dark"> <meta name="color-scheme" content="light dark">
<meta name="theme-color" content="#2563EB"> <meta name="theme-color" content="#2563EB">
<meta name="app-version" content="1.20.44"> <meta name="app-version" content="1.20.45">
<link rel="manifest" href="/manifest.webmanifest"> <link rel="manifest" href="/manifest.webmanifest">
<link rel="icon" href="/static/icon.svg" type="image/svg+xml"> <link rel="icon" href="/static/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/static/icon.svg"> <link rel="apple-touch-icon" href="/static/icon.svg">
@ -27,7 +27,7 @@
<!-- ── Core styles (local — no CDN dependency for first paint) ────────── --> <!-- ── Core styles (local — no CDN dependency for first paint) ────────── -->
<link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css"> <link rel="stylesheet" href="/static/vendor/mdi/materialdesignicons.min.css">
<link rel="stylesheet" href="/static/style.css?v=1.20.44"> <link rel="stylesheet" href="/static/style.css?v=1.20.45">
<!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── --> <!-- ── Flag icons — non-blocking (loaded async, icons appear after JS) ── -->
@ -378,7 +378,7 @@ window.toggleNavTree = function(treeId, chevronId) {
</script> </script>
<!-- loader.js: fetches sections → loads JS modules → removes skeleton --> <!-- loader.js: fetches sections → loads JS modules → removes skeleton -->
<script src="/static/loader.js?v=1.20.44"></script> <script src="/static/loader.js?v=1.20.45"></script>
</body> </body>
</html> </html>

View File

@ -46,6 +46,7 @@ test('core sections render', async ({ page }) => {
test('clone tabs switch and show one panel at a time', async ({ page }) => { test('clone tabs switch and show one panel at a time', async ({ page }) => {
await page.goto('/', { waitUntil: 'domcontentloaded' }); await page.goto('/', { waitUntil: 'domcontentloaded' });
await navTo(page, 's-clone'); await navTo(page, 's-clone');
await page.waitForFunction(() => typeof window._cloneScheduleAutoSave === 'function', null, { timeout: 15_000 });
await expect(page.locator('.clone-src-tab[data-src="url"]')).toBeVisible({ timeout: 10_000 }); await expect(page.locator('.clone-src-tab[data-src="url"]')).toBeVisible({ timeout: 10_000 });
// The app uses a fixed bottom status bar; dispatching the real DOM click // The app uses a fixed bottom status bar; dispatching the real DOM click
// avoids a viewport-dependent overlap while still exercising the handler. // avoids a viewport-dependent overlap while still exercising the handler.