2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 03:18:55 +00:00

Always sort snapshots lists ascending by timestamp

Fixes #1219.
This commit is contained in:
Fabian Wickborn 2017-09-24 12:45:14 +02:00
parent 24c62e719a
commit ea1ab96749

View File

@ -81,6 +81,11 @@ func runSnapshots(opts SnapshotOptions, gopts GlobalOptions, args []string) erro
// PrintSnapshots prints a text table of the snapshots in list to stdout.
func PrintSnapshots(stdout io.Writer, list restic.Snapshots, compact bool) {
// always sort the snapshots so that the newer ones are listed last
sort.SliceStable(list, func(i, j int) bool {
return list[i].Time.Before(list[j].Time)
})
// Determine the max widths for host and tag.
maxHost, maxTag := 10, 6
for _, sn := range list {