From 25264517a9675bc2a171c92aa7b8757df1a65021 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Wed, 19 Aug 2026 18:41:31 +0200 Subject: [PATCH] Clean up converted upload sources --- CHANGELOG.md | 5 +++++ VERSION | 2 +- routes/library.py | 14 ++++++++++++-- static/index.html | 6 +++--- tests/smoke.spec.js | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbd3237..7539d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ### Fixed diff --git a/VERSION b/VERSION index 6a36890..b741e05 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.20.44 +1.20.45 diff --git a/routes/library.py b/routes/library.py index 5da1d08..003d014 100644 --- a/routes/library.py +++ b/routes/library.py @@ -149,12 +149,22 @@ async def upload(file: UploadFile = File(...)): if suffix not in _UPLOAD_EXTS: raise HTTPException(400, "Unsupported audio/video file type") dest = TEMP_DIR / f"{uuid.uuid4().hex}{suffix}" - with dest.open("wb") as f: - _copy_limited(file.file, f, _MAX_UPLOAD_BYTES) try: + with dest.open("wb") as f: + _copy_limited(file.file, f, _MAX_UPLOAD_BYTES) wav = _to_wav_24k(dest) except Exception as e: + if isinstance(e, HTTPException): + raise 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 _registry_put(fid, wav) return {"id": fid, "duration": _duration(wav), "filename": file.filename} diff --git a/static/index.html b/static/index.html index d68fdac..35a07b2 100644 --- a/static/index.html +++ b/static/index.html @@ -10,7 +10,7 @@ - + @@ -27,7 +27,7 @@ - + @@ -378,7 +378,7 @@ window.toggleNavTree = function(treeId, chevronId) { - + diff --git a/tests/smoke.spec.js b/tests/smoke.spec.js index 7f57925..219a015 100644 --- a/tests/smoke.spec.js +++ b/tests/smoke.spec.js @@ -46,6 +46,7 @@ test('core sections render', async ({ page }) => { test('clone tabs switch and show one panel at a time', async ({ page }) => { await page.goto('/', { waitUntil: 'domcontentloaded' }); 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 }); // The app uses a fixed bottom status bar; dispatching the real DOM click // avoids a viewport-dependent overlap while still exercising the handler.