mirror of
https://github.com/Glitchy-Sheep/boosty-downloader.git
synced 2026-10-14 21:33:23 +00:00
[PR #185] [MERGED] [cache] Reset a broken cache file instead of crashing, run clean-cache through a use case #182
Labels
No labels
api-drift
bug
ci
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Glitchy-Sheep/boosty-downloader#182
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/185
Author: @Glitchy-Sheep
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @Glitchy-Sheep
Base:
main← Head:fix/cache-reinit-and-clean-cache📝 Commits (2)
9629a36[cache] Reset a broken cache file on open instead of crashingb0d2e86[cli] Run clean-cache through a use case without opening the database📊 Changes
12 files changed (+249 additions, -90 deletions)
View changed files
📝
CHANGELOG.md(+4 -0)📝
boosty_downloader/application/ports.py(+8 -0)➕
boosty_downloader/application/use_cases/clean_cache.py(+34 -0)📝
boosty_downloader/cli/commands/clean_cache.py(+15 -39)📝
boosty_downloader/cli/composition_root.py(+12 -8)📝
boosty_downloader/infrastructure/post_caching/post_cache.py(+20 -20)➕
boosty_downloader/infrastructure/post_caching/storage.py(+33 -0)📝
test/e2e/credentials_scope_test.py(+2 -9)📝
test/unit/cli/cli_smoke_test.py(+24 -0)➕
test/unit/post_caching/cache_storage_test.py(+50 -0)📝
test/unit/post_caching/post_cache_test.py(+11 -14)➕
test/unit/use_cases/clean_cache_test.py(+36 -0)📄 Description
📝 Summary
Audit stage 3, part 2 of 3: the cache stops crashing on a broken file, and
clean-cachejoins the other commands in shape.🔧 What changes
Fixed
post_cache.dbthat is not a SQLite database (truncated, overwritten, hand-edited) used to crash the run withDatabaseError: file is not a database. It now resets with the same warning an outdated schema already got. This was the one strict xfail in the suite; it is a regular test now._connectnow builds the engine, the session factory and the session together.clean-cachefailed withRuntimeError: no running event loopafter #184:load_settingsbuilt anaiohttp.CookieJar, which needs a running loop, andclean-cacheis the only sync command.AppSettingskeeps the auth header and the cookie as strings; aiohttp objects are built insideopen_app.Changed
clean-cacheruns throughCleanCacheUseCaseover aCacheStorageport.SQLiteCacheStorageworks on the files only: it never opens the database, so a missing cache is reported instead of being created and "cleaned". The folder is dropped only when nothing else is in it; downloaded posts next to the cache survive.remove_cache_completelyis gone fromSQLitePostCache: the command was its only user.🧪 Tests
SQLiteCacheStorageon tmp_path (exists, empty folder removed, folder with posts kept, no-op on a missing cache),CleanCacheUseCaseon a fake storage, and a CLI smoke that runsclean-cacheend to end with a temporary config and no event loop.task cigreen locally: ruff, pyright strict, 246 tests + e2e.post_cache.dbin a scratch cache dir makescheckprint "corrupted or inaccessible. Reinitializing..." and finish with exit 0;clean-cachetwice in a row says "cleaned" then "nothing to clean", keeps a folder that holds a post, removes an empty one;download --dry-runafterwards still reaches the API with the credentials.⏭️ Next
PR 3:
DownloadContentTypeFilterinto domain and an import-linter layers contract in CI.✅ Checklist
--helpand README if neededdocs/if the download flow or dev process changed## Unreleasedin CHANGELOG.md (or theci/skip-changeloglabel if not user-facing)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.