[PR #199] [MERGED] [cli] Ask before clean-cache removes the cache and drop the credentials requirement #198

Closed
opened 2026-10-13 19:48:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/199
Author: @Glitchy-Sheep
Created: 9/22/2026
Status: ✅ Merged
Merged: 9/22/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: fix/clean-cache-confirm


📝 Commits (1)

  • 43ed707 [cli] Ask before clean-cache removes the cache and drop the credentials requirement

📊 Changes

9 files changed (+318 additions, -48 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 boosty_downloader/application/use_cases/clean_cache.py (+10 -3)
📝 boosty_downloader/cli/cli_options.py (+10 -0)
📝 boosty_downloader/cli/commands/clean_cache.py (+26 -5)
📝 boosty_downloader/cli/composition_root.py (+38 -3)
📝 boosty_downloader/infrastructure/yaml_configuration/config.py (+59 -15)
📝 test/unit/cli/cli_smoke_test.py (+95 -17)
📝 test/unit/configuration/init_config_test.py (+44 -0)
📝 test/unit/use_cases/clean_cache_test.py (+35 -5)

📄 Description

📝 Summary

clean-cache asks before it removes the cache, and no longer needs credentials to do it. Closes the last item of audit stage 5.

🔧 What changes

  • The command says what the removal costs and asks: Cache for <creator> will be removed, the next run downloads everything again. Continue? [y/N]. A "no" keeps the cache; --yes / -y skips the question in scripts. Without a terminal and without --yes the command aborts with exit 1 instead of removing anything.
  • The command reads only the folders from the config. The auth section is not checked, so a config with empty or stale credentials still works. Without any config the defaults apply and no sample config is left behind; --cache-dir alone is enough.

💡 Why

The cache is the only record of what was downloaded: after it is gone, the next run fetches every post again. That was one keystroke away and the cost was not said anywhere. And removing a local file required a valid token, which has nothing to do with it.

🧩 How

  • read_download_settings(config_path) in the config module reads the downloading_settings section alone through a settings class of its own; a missing file gives the defaults, a broken one gets the same report as before.
  • resolve_cache_dir in the composition root shares the folder rule with load_settings.
  • CleanCacheUseCase takes a confirm callback and answers cancelled on a "no"; the question is asked only when there is a cache to remove.

🧪 Tests

  • Use case: no cache means no question; "no" keeps the cache; "yes" removes it once.
  • Config: the folders are readable from the fresh sample that whole-config loading rejects; no file gives defaults and creates nothing; a broken folders section is reported.
  • CLI smoke: the question and a "n", --yes, a credentials-free config that names the cache folder, no config and no sample. The --config tests now prove the file is read: the cache folder comes from it.
  • task ci green locally: ruff, pyright strict, import-linter, 323 tests + e2e.
  • Live with a real cache database from an empty folder: "n" keeps it and leaves no sample; no TTY aborts; --yes removes it; a config with only cache_directory and no auth works with -y.

✅ Checklist

  • Tested live on a real blog (feature or fix)
  • Updated CLI --help and README if needed
  • Updated docs/ if the download flow or dev process changed
  • Added a line to ## Unreleased in CHANGELOG.md (or the ci/skip-changelog label if not user-facing)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/199 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 9/22/2026 **Status:** ✅ Merged **Merged:** 9/22/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `fix/clean-cache-confirm` --- ### 📝 Commits (1) - [`43ed707`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/43ed70791becd2628196c89cf47a4a09f3d1c727) [cli] Ask before clean-cache removes the cache and drop the credentials requirement ### 📊 Changes **9 files changed** (+318 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `boosty_downloader/application/use_cases/clean_cache.py` (+10 -3) 📝 `boosty_downloader/cli/cli_options.py` (+10 -0) 📝 `boosty_downloader/cli/commands/clean_cache.py` (+26 -5) 📝 `boosty_downloader/cli/composition_root.py` (+38 -3) 📝 `boosty_downloader/infrastructure/yaml_configuration/config.py` (+59 -15) 📝 `test/unit/cli/cli_smoke_test.py` (+95 -17) 📝 `test/unit/configuration/init_config_test.py` (+44 -0) 📝 `test/unit/use_cases/clean_cache_test.py` (+35 -5) </details> ### 📄 Description ## 📝 Summary `clean-cache` asks before it removes the cache, and no longer needs credentials to do it. Closes the last item of audit stage 5. ## 🔧 What changes - The command says what the removal costs and asks: `Cache for <creator> will be removed, the next run downloads everything again. Continue? [y/N]`. A "no" keeps the cache; `--yes` / `-y` skips the question in scripts. Without a terminal and without `--yes` the command aborts with exit 1 instead of removing anything. - The command reads only the folders from the config. The `auth` section is not checked, so a config with empty or stale credentials still works. Without any config the defaults apply and no sample config is left behind; `--cache-dir` alone is enough. ## 💡 Why The cache is the only record of what was downloaded: after it is gone, the next run fetches every post again. That was one keystroke away and the cost was not said anywhere. And removing a local file required a valid token, which has nothing to do with it. ## 🧩 How - `read_download_settings(config_path)` in the config module reads the `downloading_settings` section alone through a settings class of its own; a missing file gives the defaults, a broken one gets the same report as before. - `resolve_cache_dir` in the composition root shares the folder rule with `load_settings`. - `CleanCacheUseCase` takes a `confirm` callback and answers `cancelled` on a "no"; the question is asked only when there is a cache to remove. ## 🧪 Tests - Use case: no cache means no question; "no" keeps the cache; "yes" removes it once. - Config: the folders are readable from the fresh sample that whole-config loading rejects; no file gives defaults and creates nothing; a broken folders section is reported. - CLI smoke: the question and a "n", `--yes`, a credentials-free config that names the cache folder, no config and no sample. The `--config` tests now prove the file is read: the cache folder comes from it. - `task ci` green locally: ruff, pyright strict, import-linter, 323 tests + e2e. - Live with a real cache database from an empty folder: "n" keeps it and leaves no sample; no TTY aborts; `--yes` removes it; a config with only `cache_directory` and no `auth` works with `-y`. ## ✅ Checklist - [x] Tested live on a real blog (feature or fix) - [ ] Updated CLI `--help` and README if needed - [x] Updated `docs/` if the download flow or dev process changed - [x] Added a line to `## Unreleased` in CHANGELOG.md (or the `ci/skip-changelog` label if not user-facing) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#198
No description provided.