List the files under a path by path, not by string prefix #250

Merged
clawbot merged 1 commits from fix-path-filter-prefix-match into next 2026-10-06 22:12:17 +02:00
Collaborator

Fixes #223.

FileRepository.ListByPrefix selected with path LIKE ? || '%', a string prefix that ignores ASCII case and treats _ and % as wildcards. Restoring /home/u/doc also restored doc2, DOC and doc.txt.bak, and a backup loaded the files of a longer sibling path as known files of this one, then counted them as deleted.

It is now ListUnderPath: the file at the path plus every file whose path starts with the path and /, compared with = and substr, which are case-sensitive and have no wildcards. Restore path arguments and the scanner's known-file load both use it.

What the diff does not show:

  • A trailing slash on the argument is stripped, so / still lists every file and doc/ lists the same as doc. Restore already cleans its arguments with filepath.Clean.
  • The subtree half of the query cannot use idx_files_path; the LIKE it replaces could not either.
  • Three existing tests relied on string-prefix matching (/concurrent-, /tx-test, and an empty prefix over relative paths) and now name a full path or call ListAll.

Judgement call: ListIDsWithChunksNotInUploadedBlobs keeps its LIKE. Its result is only consulted for files found under the scanned path, so the extra IDs it can return are never looked up; changing it is outside the issue.

Judgement call: renamed to ListUnderPath, since the old name describes the string-prefix behaviour that caused the defect.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/vaultik/issues/223. `FileRepository.ListByPrefix` selected with `path LIKE ? || '%'`, a string prefix that ignores ASCII case and treats `_` and `%` as wildcards. Restoring `/home/u/doc` also restored `doc2`, `DOC` and `doc.txt.bak`, and a backup loaded the files of a longer sibling path as known files of this one, then counted them as deleted. It is now `ListUnderPath`: the file at the path plus every file whose path starts with the path and `/`, compared with `=` and `substr`, which are case-sensitive and have no wildcards. Restore path arguments and the scanner's known-file load both use it. What the diff does not show: - A trailing slash on the argument is stripped, so `/` still lists every file and `doc/` lists the same as `doc`. Restore already cleans its arguments with `filepath.Clean`. - The subtree half of the query cannot use `idx_files_path`; the `LIKE` it replaces could not either. - Three existing tests relied on string-prefix matching (`/concurrent-`, `/tx-test`, and an empty prefix over relative paths) and now name a full path or call `ListAll`. Judgement call: `ListIDsWithChunksNotInUploadedBlobs` keeps its `LIKE`. Its result is only consulted for files found under the scanned path, so the extra IDs it can return are never looked up; changing it is outside the issue. Judgement call: renamed to `ListUnderPath`, since the old name describes the string-prefix behaviour that caused the defect. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 20:34:26 +02:00
clawbot self-assigned this 2026-10-06 20:34:26 +02:00
Author
Collaborator

Review passed.
Model: opus-5-5

Review passed. Model: opus-5-5
clawbot added 1 commit 2026-10-06 21:39:01 +02:00
FileRepository.ListByPrefix matched with SQL LIKE: a plain string
prefix that ignores ASCII case and treats _ and % as wildcards.
Restoring /home/u/doc also restored doc2, DOC and doc.txt.bak, and a
backup counted the files of a longer sibling path as deleted. It is
now ListUnderPath, which returns the file at the path and every file
whose path starts with the path plus a slash, compared exactly. A
trailing slash is ignored, so "/" still lists every file.

Three tests relied on string-prefix matching and now name a full path
or call ListAll.

ListIDsWithChunksNotInUploadedBlobs keeps its LIKE: it only adds file
IDs the scan never looks up.

Model: opus-5-5
clawbot force-pushed fix-path-filter-prefix-match from bea6c4acec to eca82738af 2026-10-06 21:39:01 +02:00 Compare
Author
Collaborator

Rebased onto current next after #249 landed; the only conflict was TODO.md, resolved by keeping both Completed Steps entries (this one first). Nothing else changed.

Model: opus-5-5

Rebased onto current `next` after https://git.eeqj.de/sneak/vaultik/pulls/249 landed; the only conflict was `TODO.md`, resolved by keeping both Completed Steps entries (this one first). Nothing else changed. Model: opus-5-5
Author
Collaborator

Review passed.
Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 5d685f03ce into next 2026-10-06 22:12:17 +02:00
clawbot deleted branch fix-path-filter-prefix-match 2026-10-06 22:12:17 +02:00
Sign in to join this conversation.