Start empty when the cache directory holds another account's cache (closes #104) #113

Merged
clawbot merged 1 commits from issue-104-cache-account into next2 2026-09-23 05:56:14 +02:00
Collaborator

Fixes #104.

Library.open now checks the user ID stored in metadata.json. When it is non-zero and differs from the client's, it deletes metadata.json and mldata/ and loads an empty store. The first refresh then runs from a zero cursor, and none of the other account's collections, files, keys or ML results are served. This can only happen with --cache-dir or an explicit cacheDirectory, because the default path already includes the user ID.

What the diff does not show:

  • A stored user ID of 0 is left alone. A saved cache always has one, since the first refresh that writes the file sets it.
  • Cached originals and thumbnails are kept. They are looked up by file ID through the store's records, so the other account's files cannot be reached once its records are gone. The README cache layout section now says this.
  • Because the store is now empty, the first refresh is awaited, the same as on a first run.

The new test in test/library/mldata.test.ts fills a cache as one account and opens it as another. It fails without the change.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/quak/issues/104. `Library.open` now checks the user ID stored in `metadata.json`. When it is non-zero and differs from the client's, it deletes `metadata.json` and `mldata/` and loads an empty store. The first refresh then runs from a zero cursor, and none of the other account's collections, files, keys or ML results are served. This can only happen with `--cache-dir` or an explicit `cacheDirectory`, because the default path already includes the user ID. What the diff does not show: - A stored user ID of 0 is left alone. A saved cache always has one, since the first refresh that writes the file sets it. - Cached originals and thumbnails are kept. They are looked up by file ID through the store's records, so the other account's files cannot be reached once its records are gone. The README cache layout section now says this. - Because the store is now empty, the first refresh is awaited, the same as on a first run. The new test in `test/library/mldata.test.ts` fills a cache as one account and opens it as another. It fails without the change. Model: opus-5-5
clawbot added the needs-review label 2026-09-23 05:39:17 +02:00
clawbot self-assigned this 2026-09-23 05:39:17 +02:00
Author
Collaborator

PASS on 5afd7c4 rebased onto next2 d05b53d.

Model: opus-5-5

PASS on `5afd7c4` rebased onto `next2` `d05b53d`. Model: opus-5-5
clawbot added 1 commit 2026-09-23 05:55:12 +02:00
When metadata.json in the cache directory was written for a different,
non-zero user ID than the client's, Library.open deletes it and mldata/
and loads an empty store, so the first refresh enumerates from 0 and none
of the other account's collections, files, keys or ML results are served.
Only reachable with --cache-dir or an explicit cacheDirectory.

Model: opus-5-5
clawbot force-pushed issue-104-cache-account from 5afd7c4bd7 to 8689e00232 2026-09-23 05:55:12 +02:00 Compare
clawbot merged commit 390401af2c into next2 2026-09-23 05:56:14 +02:00
clawbot deleted branch issue-104-cache-account 2026-09-23 05:56:15 +02:00
Sign in to join this conversation.