Repository navigation
refactor(tools): rewrite qbit-ctl as a dependency-free Python console - #58
Merged
Merged
Conversation
The bash/whiptail version installed sqlite3 with apk on every query, which broke when newer sqlite3 rejected `.mode tab`, and had data-safety gaps: hot tar backups of a WAL database, restores that extracted over the old files (or ran with the backend up), partial library deletes, and columns that shifted on NULLs or `|`. qbit-ctl is now a single Python 3.10+ file using only the standard library (curses). All data access runs inside the backend image (node + better-sqlite3), via `docker exec` or a throwaway container when the backend is stopped, so no network or extra packages are needed. - Backups: VACUUM INTO snapshot taken before files/ is copied, integrity-checked, written atomically; consistent while the backend runs. - Restore: validate the archive in a container without the live volume, stop the backend, save a safety backup, empty the volume, extract, wait for the health check. A failed extract puts the safety backup back. Ctrl-C and SIGHUP cannot interrupt it. - Library delete runs in one transaction; restarting the backend to refresh its cache is offered, not forced. - Console tabs: overview, backups, database (11 read-only queries), library, volume; commands `status`, `backup` and `backups` for scripts. - Backup directory: --dir, $QBIT_CTL_BACKUP_DIR, [backups] dir in $XDG_CONFIG_HOME/qbit-ctl/config.ini (set or reset from the console), then ~/qbit_backups. The archive name and layout are unchanged. - Unit tests run every query against the schema in web/backend/src/db.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rewrites
tools/qbit-ctlas a single Python 3.10+ file that uses only the standard library (curses). The bash/whiptail version broke when newer sqlite3 rejected.mode tab, and had data-safety gaps (hot tar backups of a WAL database, restores that extracted over the old files or ran with the backend up, partial library deletes, columns shifting on NULL or|).All data access now runs inside the backend image (node + better-sqlite3):
docker execwhile the backend runs, a throwaway container when it is stopped. No network access orapk addis needed, and the SQLite version always matches the backend.What changes
VACUUM INTOsnapshot taken beforefiles/is copied, integrity-checked, written atomically. Consistent while the backend keeps serving. Archive name and layout are unchanged (qbit-data-backup-<ts>.tar.gzwithqbit.db,secrets.json,files/).restoreto confirm.status,backup,backups.--dir>$QBIT_CTL_BACKUP_DIR>[backups] dirin$XDG_CONFIG_HOME/qbit-ctl/config.ini(set or reset from the console) >~/qbit_backups.Tools (qbit-ctl)job, run whentools/orweb/backend/src/db.tschanges; included in the requiredcicheck.Testing
web/backend/src/db.ts.NO_COLOR, small and very wide terminals.Deployment impact
None for the running services: only the operator script changes. Update the checkout on the server with
git pull --ff-only; no rebuild or restart.