Skip to content

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

Closed
thereisnotime wants to merge 26 commits into
eddyizm:mainfrom
thereisnotime:fix/delete-download-nukes-folder
Closed

fix: only delete app-managed files when clearing download storage#672
thereisnotime wants to merge 26 commits into
eddyizm:mainfrom
thereisnotime:fix/delete-download-nukes-folder

Conversation

@thereisnotime
Copy link
Copy Markdown

Fixes #588.

What was happening

DeleteDownloadStorageDialog called file.delete() on every file in the user-selected download 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

tvillega and others added 23 commits May 8, 2026 07:52
* feat: handle crashes gracefully

* fix: missing strings

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
* First tests

# Conflicts:
#	app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt
#	app/src/main/res/values-b+es+419/arrays.xml
#	app/src/main/res/values-de/arrays.xml
#	app/src/main/res/values-es-rES/arrays.xml
#	app/src/main/res/values-fr/arrays.xml
#	app/src/main/res/values-pl/arrays.xml
#	app/src/main/res/values-ru/arrays.xml
#	app/src/main/res/values/arrays.xml
#	app/src/main/res/xml/global_preferences.xml
#	app/src/tempus/java/com/cappielloantonio/tempo/service/MediaBrowserTree.kt

* Corrections after rebase

* final version

* Added index guard

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
Co-authored-by: eddyizm <eddyizm@gmail.com>
* Add eddyizm#576

* eddyizm#570 (arrays.xml)

* eddyizm#570 (strings.xml)

* Add eddyizm#595

* for you

* Add eddyizm#606

* Add eddyizm#609

* Add eddyizm#620 and rename replaygain

* typo

* Missing stuff

* Add eddyizm#617

* Add eddyizm#611

* Add eddyizm#614 (strings.xml)

* Add eddyizm#614 (arrays.xml)
…ddyizm#617)

* Implement sleep timer

* Revert "Implement sleep timer"

* Implement sleep timer

* Sleep timer adjustments and custom time option

* Sleep timer localizations, theming, and new features

1. Process-death survival 
2. End-of-track mode
3. Fade-out 
4. Theme-aware icon
5. Localized duration labels

* Sleep timer "End of track" fix

* Fade out fix

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
Refactor custom commands

Co-authored-by: eddyizm <eddyizm@gmail.com>
* feat: saving full playlist detail in db and created pinned playlist table to track faves

* chore: uncommented automigration

* feat: added sorting by date, song count, pinned, etc

* feat: added preference auto saving and apply to home view.

* feat: saving playlist id/name to download track

* feat: expands playlsit sorting and adds back pinned/faves
* Implement sleep timer

* Revert "Implement sleep timer"

* Implement sleep timer

* Sleep timer adjustments and custom time option

* feat: add lyrics to player quick actions

* Sleep timer localizations, theming, and new features

1. Process-death survival 
2. End-of-track mode
3. Fade-out 
4. Theme-aware icon
5. Localized duration labels

* Sleep timer "End of track" fix

* Fade out fix

* feat: add lyrics to player quick actions

---------

Co-authored-by: CtznSniiips <88013463+CtznSniiips@users.noreply.github.com>
Co-authored-by: eddyizm <eddyizm@gmail.com>
* chore(i18n): Update Spanish (Spain, es-ES) translation

* chore(i18n): Update Spanish (Spain, es-ES) translation

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
style: Add darker/AMOLED theme

Co-authored-by: eddyizm <eddyizm@gmail.com>
* feat: save radio list locally for offline access (eddyizm#520)

Cache internet radio stations to Room database on successful API fetch.
Fall back to cached data when server is unreachable (HTTP 504 or
network failure), ensuring the radio list remains available offline.

* fix: fall back to original radio media item when server is unreachable

When the Subsonic server is down, AutomotiveRepository.getInternetRadioStations()
throws an exception. Wrap the call with Futures.catchingAsync() to fall back
to the original media item so radio playback works offline.

---------

Co-authored-by: Rouven Volkmann <gitlab@rouven-volkmann.de>
* Initial working version of modified startQueue function that starts the first 10 songs before loading the rest

* Minor change to enqueue function to collect media details off the main thread
Tidied up startQueue function changes

* removed accidental duplicate queue task

* avoid duplicate calls

* removed imports used in testing

* remove the listener before running enqueue so we dont accidently run it multiple times if the player changes state before enqueue completes

---------

Co-authored-by: Arrillo Dev <opensource@arrillo.com>
Remove AA settings in degoogled flavor

Co-authored-by: eddyizm <eddyizm@gmail.com>
Limiting number of tracks in playlists

Co-authored-by: eddyizm <eddyizm@gmail.com>
…eForYouBuilder (eddyizm#640)

reduce code duplication

Co-authored-by: eddyizm <eddyizm@gmail.com>
* fix: equalizer glitching navigation

* fix: inconsistent navigation on equalizer

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
* feat: add settings for track number display

* feat: add track number on now playing screen

* chore: better description of setting

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
* feat: add drawer to landscape layout of crash activity
and remove the bottom navbar on landscape as well

* feat: add landscape layout to crash info fragment

* feat: add landscape layout to crash export fragment

* feat: add landscape layout to crash logs fragment

* fix: toolbar not initiated nor configured

---------

Co-authored-by: eddyizm <eddyizm@gmail.com>
…position (eddyizm#651)

If the current period is seekable, it is very likely that the audio
file is not being transcoded and that reloading the source would result
in playback being restarted from the start the file.

Fixes eddyizm#650.

Co-authored-by: eddyizm <eddyizm@gmail.com>
@eddyizm
Copy link
Copy Markdown
Owner

eddyizm commented May 16, 2026

Hi @thereisnotime If you can separate the ci workflow from this PR, it can get reviewed on its own.

@thereisnotime
Copy link
Copy Markdown
Author

The CI workflow is in a separate PR (#671) — this one only touches the three Java files for the download deletion fix. Happy to retarget both this and #674 to the development branch if that's preferred.

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
Copy link
Copy Markdown
Author

Superseded by #675 which targets the development branch.

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.

[BUG] - Delete saved items nukes the entire folder