fix: don't auto-purge the desktop library (skip job TTL sweep) by thcp · Pull Request #229 · stemdeckapp/stemdeck · GitHub
Skip to content

fix: don't auto-purge the desktop library (skip job TTL sweep)#229

Merged
thcp merged 1 commit into
mainfrom
fix/desktop-no-job-sweep
Jun 26, 2026
Merged

fix: don't auto-purge the desktop library (skip job TTL sweep)#229
thcp merged 1 commit into
mainfrom
fix/desktop-no-job-sweep

Conversation

@thcp

@thcp thcp commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Problem

On desktop, the library track list is persisted permanently in ~/Documents/StemDeck/user-data.json, but the stems under jobs/<id>/ are subject to the 24h job TTL sweep that runs at every server startup. So a day later — or whenever the app restarts past the TTL, e.g. installing a new release — the sweep deletes the stems while the library entries survive, leaving orphaned tracks that show:

This track's audio is no longer available. Re-upload to restore it.

Users read this as "every new release loses my songs", but it's really the TTL firing on the post-update restart (reopening the app the next day does the same).

Fix

The TTL is a sensible disk-hygiene default for the shared server / Docker deployment. On desktop the library is user-curated (folders + Trash), so the sweep shouldn't auto-purge it. Skip the sweep when running under the desktop shell — STEMDECK_DESKTOP=1, which the Tauri launcher sets unconditionally on Windows, macOS, and Linux (main.rs:595). Disk usage stays under the user's control via the existing Trash/delete UI. The server/Docker path is unchanged.

Scope

  • One-file backend change (app/main.py): _sweep_loop returns early when _sweep_disabled() (desktop).
  • Applies to all three desktop platforms (shared Python backend + platform-agnostic env var).

Tests

  • _sweep_disabled() true under STEMDECK_DESKTOP=1, false otherwise.
  • _sweep_loop() returns immediately (doesn't enter the hourly loop) in desktop mode.
  • Full suite: 109 passed, ruff check + ruff format --check clean.

The desktop app persists its track list permanently in
~/Documents/StemDeck/user-data.json, but stems under jobs/<id>/ were
subject to the 24h job TTL sweep that runs at every startup. After a day
(or any app restart past the TTL -- e.g. installing a new release) the
sweep deleted the stems while the library entries remained, surfacing
"This track's audio is no longer available. Re-upload to restore it."

The TTL is a disk-hygiene default for the shared server/Docker deployment.
On desktop the library is user-curated (folders + Trash), so skip the
sweep when running under the desktop shell (STEMDECK_DESKTOP=1, set by the
Tauri launcher on Windows/macOS/Linux). Disk stays under user control.
@thcp thcp merged commit cbc64fd into main Jun 26, 2026
8 checks passed
@thcp thcp deleted the fix/desktop-no-job-sweep branch June 26, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant