Skip to content

feat: zstash ls --tars filters to tars containing matched files - #457

Draft
forsyth2 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-tar-association-feature
Draft

feat: zstash ls --tars filters to tars containing matched files#457
forsyth2 with Copilot wants to merge 2 commits into
mainfrom
copilot/add-tar-association-feature

Conversation

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Previously zstash ls --tars always dumped every tar in the archive regardless of any file filter. Users wanting to download a subset of the archive (e.g. "years 1850–1900 from the historical run") had no way to identify which specific tars they needed.

Objectives:

  • Make --tars show only the tars that contain the files matched by the [files] glob pattern
  • Add unit tests covering filtered and unfiltered cases
  • Document the workflow with an end-to-end example

Select one: This pull request is...

  • a bug fix: increment the patch version
  • a small improvement: increment the minor version
  • a new feature: increment the minor version
  • an incompatible (non-backwards compatible) API change: increment the major version

Small Change

  • To merge, I will use "Squash and merge". That is, this change should be a single commit.
  • Logic: I have visually inspected the entire pull request myself.
  • Pre-commit checks: All the pre-commits checks have passed.

Copilot AI and others added 2 commits August 21, 2026 17:47
Co-authored-by: forsyth2 <30700190+forsyth2@users.noreply.github.com>
When `--tars` is used with a file glob, only the tars containing
the matched files are shown, making it easy to identify the subset
of archives needed for a partial download.

- Modified `ls_tars_database` to accept an optional `tar_names`
  list; when provided it filters the SQL query to those names
- `ls()` extracts unique tar names from matched `FilesRow` results
  and passes them to `ls_tars_database`
- Added unit tests in `tests/unit/test_ls.py`
- Updated documentation with a filtering example

Co-authored-by: forsyth2 <30700190+forsyth2@users.noreply.github.com>
@forsyth2

Copy link
Copy Markdown
Collaborator

Alternative approach that doesn't involve zstash code change:

# Find the db file zstash is using (see get_db_filename() in settings.py for the exact path;
# typically something like <cache>/index.db)
DB=zstash/index.db

sqlite3 -header -column "$DB" "
  SELECT DISTINCT tars.*
  FROM tars
  JOIN files ON files.tar = tars.name
  WHERE files.name GLOB '*historical*'
  ORDER BY tars.name;
"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants