quak get and get-thumb on an empty cache stop fetching collections once they find the file (closes #222)
check / check (push) Waiting to run

`quak get` and `quak get-thumb` used to wait for a refresh, which on an
empty cache fetched the files of every collection. Now, on an empty
cache, `freshFile` reads the collection list, then one collection's
files at a time, and stops at the first that holds the file. That search
stores nothing. Once the cache holds the account's collections,
`freshFile` refreshes as before and looks the file up in the cache. The
commands fetch the content through the new `Library.originalOf()` and
`Library.thumbnailOf()`, which take the file record itself, since the
store may not hold it.

On an empty cache they no longer print a refresh's progress lines. The
`-q` test that relied on `get` refreshing now runs
`helper fix-missing-thumbnails`.

Model: opus-5-5
This commit was merged in pull request #226.
This commit is contained in:
2026-10-26 10:18:28 +01:00
parent af1491966c
commit f65c237e2c
11 changed files with 278 additions and 109 deletions
+9 -10
View File
@@ -133,8 +133,9 @@ const readLibraryClient = (client: Client): LibraryClient => ({
// not start downloading the whole account. No refresh starts as the library
// opens or on a timer. Each command asks for the refresh it needs.
// `collections` and `files` with a collection ID need none (issues #210 and
// #217). While a refresh runs, each collection whose files it has fetched is
// logged, so a large account shows progress rather than nothing.
// #217). Nor do `get` and `get-thumb` on an empty cache (issue #222). While a
// refresh runs, each collection whose files it has fetched is logged, so a
// large account shows progress rather than nothing.
const openReadLibrary = (ctx: CliContext, client: Client): Promise<Library> =>
Library.open({
client: readLibraryClient(client),
@@ -324,14 +325,13 @@ export const getCommand = async (
try {
// Force a server round-trip so the file resolves against current state
// (issue #36 amendment, issue #52).
const resolved = await freshFile(lib, fileID);
if (!resolved) {
const file = await freshFile(lib, fileID);
if (!file) {
ctx.log("fatal", `File ${fileID} not found`);
return 1;
}
const { photo, file } = resolved;
const result = await photo.original();
const result = await lib.originalOf(file);
// Default name is the file's own title, as the pre-library CLI used
// (not the editedName-preferring projection title) (issue #52).
if (result.videoPath === undefined) {
@@ -382,14 +382,13 @@ export const getThumbCommand = async (
try {
// Force a server round-trip so the file resolves against current state
// (issue #36 amendment, issue #52).
const resolved = await freshFile(lib, fileID);
if (!resolved) {
const file = await freshFile(lib, fileID);
if (!file) {
ctx.log("fatal", `File ${fileID} not found`);
return 1;
}
const { photo, file } = resolved;
const result = await photo.thumbnail();
const result = await lib.thumbnailOf(file);
// Default name is thumb_<file's own title>, as the pre-library CLI
// used (not the projection title) (issue #52).
const outPath = opts.out ?? thumbnailName(file);