Skip to content

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

Open
thereisnotime wants to merge 3 commits into
eddyizm:developmentfrom
thereisnotime:fix/delete-download-nukes-folder
Open

fix: only delete app-managed files when clearing download storage#675
thereisnotime wants to merge 3 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

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
Comment thread justfile Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be in this pr.

Comment thread .github/workflows/ci.yml Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please exclude this workflow.

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