The zfs backup tool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zfs_backup_tool/snapshotlist.go

36 lines
779 B

package main
type snapshotList struct {
Snapshots []Snapshot
}
func (snapList snapshotList) addSnapshot(snap Snapshot) {
if len(snapList.Snapshots) == 0 {
snapList.Snapshots = append(snapList.Snapshots, snap)
}
snapList.Snapshots = append(snapList.Snapshots, snap)
}
/*
Len is required for the sort interface.
*/
func (snapList snapshotList) Len() int {
return len(snapList.Snapshots)
}
/*
Less is required for the sort interface.
*/
func (snapList snapshotList) Less(i, j int) bool {
return snapList.Snapshots[i].TimeStamp.Before(
snapList.Snapshots[j].TimeStamp)
}
/*
Swap is required for the sort interface.
*/
func (snapList snapshotList) Swap(i, j int) {
t := snapList.Snapshots[i]
snapList.Snapshots[i] = snapList.Snapshots[j]
snapList.Snapshots[j] = t
}