mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Fix type of ID field in cmd_snapshots
type Snapshot
This commit is contained in:
parent
208edaa3d1
commit
26e266a951
@ -166,7 +166,7 @@ func printSnapshotsReadable(stdout io.Writer, list []*restic.Snapshot) {
|
|||||||
type Snapshot struct {
|
type Snapshot struct {
|
||||||
*restic.Snapshot
|
*restic.Snapshot
|
||||||
|
|
||||||
ID string `json:"id"`
|
ID *restic.ID `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// printSnapshotsJSON writes the JSON representation of list to stdout.
|
// printSnapshotsJSON writes the JSON representation of list to stdout.
|
||||||
@ -178,7 +178,7 @@ func printSnapshotsJSON(stdout io.Writer, list []*restic.Snapshot) error {
|
|||||||
|
|
||||||
k := Snapshot{
|
k := Snapshot{
|
||||||
Snapshot: sn,
|
Snapshot: sn,
|
||||||
ID: sn.ID().String(),
|
ID: sn.ID(),
|
||||||
}
|
}
|
||||||
snapshots = append(snapshots, k)
|
snapshots = append(snapshots, k)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func testRunFind(t testing.TB, gopts GlobalOptions, pattern string) []string {
|
|||||||
return strings.Split(string(buf.Bytes()), "\n")
|
return strings.Split(string(buf.Bytes()), "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRunSnapshots(t testing.TB, gopts GlobalOptions) (*Snapshot, map[string]Snapshot) {
|
func testRunSnapshots(t testing.TB, gopts GlobalOptions) (newest *Snapshot, snapmap map[restic.ID]Snapshot) {
|
||||||
buf := bytes.NewBuffer(nil)
|
buf := bytes.NewBuffer(nil)
|
||||||
globalOptions.stdout = buf
|
globalOptions.stdout = buf
|
||||||
globalOptions.JSON = true
|
globalOptions.JSON = true
|
||||||
@ -177,15 +177,14 @@ func testRunSnapshots(t testing.TB, gopts GlobalOptions) (*Snapshot, map[string]
|
|||||||
snapshots := []Snapshot{}
|
snapshots := []Snapshot{}
|
||||||
OK(t, json.Unmarshal(buf.Bytes(), &snapshots))
|
OK(t, json.Unmarshal(buf.Bytes(), &snapshots))
|
||||||
|
|
||||||
var newest *Snapshot
|
snapmap = make(map[restic.ID]Snapshot, len(snapshots))
|
||||||
snapmap := make(map[string]Snapshot, len(snapshots))
|
|
||||||
for _, sn := range snapshots {
|
for _, sn := range snapshots {
|
||||||
snapmap[sn.ID] = sn
|
snapmap[*sn.ID] = sn
|
||||||
if newest == nil || sn.Time.After(newest.Time) {
|
if newest == nil || sn.Time.After(newest.Time) {
|
||||||
newest = &sn
|
newest = &sn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newest, snapmap
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRunForget(t testing.TB, gopts GlobalOptions, args ...string) {
|
func testRunForget(t testing.TB, gopts GlobalOptions, args ...string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user