diff --git a/src/restic/snapshot.go b/src/restic/snapshot.go index f56d0bdd0..71dbc0f70 100644 --- a/src/restic/snapshot.go +++ b/src/restic/snapshot.go @@ -172,6 +172,24 @@ func (sn *Snapshot) SamePaths(paths []string) bool { return sn.HasPaths(paths) } +// Snapshots is a list of snapshots. +type Snapshots []*Snapshot + +// Len returns the number of snapshots in sn. +func (sn Snapshots) Len() int { + return len(sn) +} + +// Less returns true iff the ith snapshot has been made after the jth. +func (sn Snapshots) Less(i, j int) bool { + return sn[i].Time.After(sn[j].Time) +} + +// Swap exchanges the two snapshots. +func (sn Snapshots) Swap(i, j int) { + sn[i], sn[j] = sn[j], sn[i] +} + // ErrNoSnapshotFound is returned when no snapshot for the given criteria could be found. var ErrNoSnapshotFound = errors.New("no snapshot found") diff --git a/src/restic/snapshot_filter.go b/src/restic/snapshot_policy.go similarity index 86% rename from src/restic/snapshot_filter.go rename to src/restic/snapshot_policy.go index 450b2acc2..967d388a4 100644 --- a/src/restic/snapshot_filter.go +++ b/src/restic/snapshot_policy.go @@ -6,24 +6,6 @@ import ( "time" ) -// Snapshots is a list of snapshots. -type Snapshots []*Snapshot - -// Len returns the number of snapshots in sn. -func (sn Snapshots) Len() int { - return len(sn) -} - -// Less returns true iff the ith snapshot has been made after the jth. -func (sn Snapshots) Less(i, j int) bool { - return sn[i].Time.After(sn[j].Time) -} - -// Swap exchanges the two snapshots. -func (sn Snapshots) Swap(i, j int) { - sn[i], sn[j] = sn[j], sn[i] -} - // ExpirePolicy configures which snapshots should be automatically removed. type ExpirePolicy struct { Last int // keep the last n snapshots