Skip to content

Bugfix: restic find --pack <tree-pack> did not produce output for tree packs#5664

Merged
MichaelEischer merged 8 commits into
restic:masterfrom
wplapper:cmd_find_tree_pack
Feb 25, 2026
Merged

Bugfix: restic find --pack <tree-pack> did not produce output for tree packs#5664
MichaelEischer merged 8 commits into
restic:masterfrom
wplapper:cmd_find_tree_pack

Conversation

@wplapper

@wplapper wplapper commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

cmd/restic/cmd_find.go: now produces output for both data-blob and tree-blob packfiles.
In func packsToBlobs() the blob type is now checked and the blob is either inserted into f.blobIDs or f.treeIDs.

What does this PR change? What problem does it solve?

This PR fixes a bug in restic find --pack.

Was the change previously discussed in an issue or on the forum?

Yes, in #5280

Checklist

  • I have added tests for all code changes.
  • [ ] I have added documentation for relevant changes (in the manual).
  • There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I'm done! This pull request is ready for review.

@wplapper wplapper marked this pull request as draft January 10, 2026 16:20
@wplapper wplapper marked this pull request as ready for review January 10, 2026 21:14
wplapper added a commit to wplapper/restic that referenced this pull request Jan 17, 2026
Added three more tests
- TestFindOldestNewest() to find a file in the repository where the ModTime of the
  file is within the specified range of options `--oldest`, `--newest'
- TestFindBlobID() which finds the the data blob with a given ID
- TestFindPackID() which finds all (data) blobs in a given packfile

Note: there should be more tests once PR restic#5664 has been applied, which will test
      option `--pack` and option `--show-pack-id`
cmd/restic/cmd_find.go: now produces output for both data-blob and
tree-blob packfiles.
In func packsToBlobs() the Type of the blob is now checked and inserts
the blob either into f.blobIDs or into f.treeIDs.
cmd/restic/cmd_find.go:
linter suggests switch b.Type instead if / else if
cmd/restic/cmd_find_integration_test.go:
Added integration test for `restic find --pack <tree-packfile>
using JSON output option.

restic find - correct integration errors

cmd/restic/cmd_find_integration_test.go:
1.) linter spelling correction: it wants 'JSON...'
2.) Windows path are special

restic find - windows problems

cmd/restic/cmd_find_integration_test.go:
I can't be bothered to work out how to convert \\ to /, so I excluded the test for windows

@MichaelEischer MichaelEischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for a few nits, see below.

Comment thread cmd/restic/cmd_find_integration_test.go Outdated
Comment thread cmd/restic/cmd_find_integration_test.go Outdated
corrected spelling mistake
try to get Windows test to work as well
sorry, forgot to gofmt!
shortened the the string to exclude the drive mapping
mistyped string 'backupPath'

@MichaelEischer MichaelEischer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@MichaelEischer MichaelEischer merged commit f9b6305 into restic:master Feb 25, 2026
11 checks passed
@wplapper wplapper deleted the cmd_find_tree_pack branch February 26, 2026 01:01
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