Skip to content

fix: only delete app-managed files when clearing download storage#675

Merged
eddyizm merged 5 commits into
eddyizm:developmentfrom
thereisnotime:fix/delete-download-nukes-folder
May 25, 2026
Merged

fix: only delete app-managed files when clearing download storage#675
eddyizm merged 5 commits into
eddyizm:developmentfrom
thereisnotime:fix/delete-download-nukes-folder

Conversation

@thereisnotime
Copy link
Copy Markdown

Fixes #588.

Supersedes #672 (which targeted main by mistake).

What was happening

DeleteDownloadStorageDialog called file.delete() on every file in the user-selected folder with no ownership check. If the user pointed the app at a folder that also contained other files, those were deleted too.

Fix

Before deleting, each file is now checked against ExternalDownloadMetadataStore. Only files the app recorded as downloads are removed.

ExternalDownloadMetadataStore gets two new methods:

  • isTrackedFile(String fileName) — strips the extension, normalizes the base name, and checks the store
  • normalizeKey(String name) — the shared normalization logic (previously duplicated privately in ExternalAudioWriter); ExternalAudioWriter.normalizeForComparison now delegates to it so both stay in sync

Changes

  • DeleteDownloadStorageDialog.java — guard file.delete() with isTrackedFile check
  • ExternalDownloadMetadataStore.java — add isTrackedFile and normalizeKey
  • ExternalAudioWriter.java — delegate normalizeForComparison to normalizeKey, remove duplicate logic

Comment thread justfile Outdated
Comment thread .github/workflows/ci.yml Outdated
justfile covers the most common dev tasks: debug/release builds for both
flavors, lint, unit tests, APK listing, dependency inspection, and
Gradle wrapper upgrades.

CI runs lint + unit tests on every push and PR to main/development,
then gates a debug build on passing checks. Lint reports and test
results are uploaded as artifacts for easy inspection.
The delete loop in DeleteDownloadStorageDialog was calling file.delete()
on every file in the user-selected folder, wiping anything else stored
there alongside app downloads.

Now it checks each filename against ExternalDownloadMetadataStore before
deleting, so only files the app actually downloaded are removed.

The normalization logic that was duplicated in ExternalAudioWriter is
consolidated into ExternalDownloadMetadataStore.normalizeKey() so both
codepaths stay in sync.

Fixes eddyizm#588
@thereisnotime thereisnotime force-pushed the fix/delete-download-nukes-folder branch from 9a95afa to d317ee8 Compare May 23, 2026 21:47
@eddyizm eddyizm merged commit d6ab052 into eddyizm:development May 25, 2026
@eddyizm
Copy link
Copy Markdown
Owner

eddyizm commented May 25, 2026

Hi @thereisnotime <
I'm reverting this PR.
It does not delete the actual music files even though it removes them from the database/app.
Please feel free to rework it and provide some evidence of testing with screenshots.

eddyizm added a commit that referenced this pull request May 25, 2026
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.

2 participants