Skip to content

Commit

Permalink
snapshots sorted by timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunajesh authored and MichaelEischer committed Jul 23, 2023
1 parent 98fb56b commit 32f5ee6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/issue-1495
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Snapshots are sorted by timestamp in the output of `restic find`

The `find` command printed snapshots in an arbitrary order. Now restic prints
the snapshots sorted by timestamp.

https://github.com/restic/restic/issues/1495
https://github.com/restic/restic/pull/4409
9 changes: 9 additions & 0 deletions cmd/restic/cmd_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,16 @@ func runFind(ctx context.Context, opts FindOptions, gopts GlobalOptions, args []
}
}

var filteredSnapshots []*restic.Snapshot
for sn := range FindFilteredSnapshots(ctx, snapshotLister, repo, &opts.SnapshotFilter, opts.Snapshots) {
filteredSnapshots = append(filteredSnapshots, sn)
}

sort.Slice(filteredSnapshots, func(i, j int) bool {
return filteredSnapshots[i].Time.Before(filteredSnapshots[j].Time)
})

for _, sn := range filteredSnapshots {
if f.blobIDs != nil || f.treeIDs != nil {
if err = f.findIDs(ctx, sn); err != nil && err.Error() != "OK" {
return err
Expand Down

0 comments on commit 32f5ee6

Please # to comment.