From 61e827ae4f88356362efcff3a730d3115c5854a2 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 3 Oct 2022 14:30:48 +0200 Subject: [PATCH] restic: hide findLatestSnapshot --- internal/restic/snapshot_find.go | 8 ++++---- internal/restic/snapshot_find_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/restic/snapshot_find.go b/internal/restic/snapshot_find.go index 6c94dbe29..a6df84cca 100644 --- a/internal/restic/snapshot_find.go +++ b/internal/restic/snapshot_find.go @@ -12,8 +12,8 @@ import ( // ErrNoSnapshotFound is returned when no snapshot for the given criteria could be found. var ErrNoSnapshotFound = errors.New("no snapshot found") -// FindLatestSnapshot finds latest snapshot with optional target/directory, tags, hostname, and timestamp filters. -func FindLatestSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, targets []string, +// findLatestSnapshot finds latest snapshot with optional target/directory, tags, hostname, and timestamp filters. +func findLatestSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, targets []string, tagLists []TagList, hostnames []string, timeStampLimit *time.Time) (ID, error) { var err error @@ -91,7 +91,7 @@ func FindSnapshot(ctx context.Context, be Lister, s string) (ID, error) { func FindFilteredSnapshot(ctx context.Context, be Lister, loader LoaderUnpacked, hosts []string, tags []TagList, paths []string, timeStampLimit *time.Time, snapshotID string) (ID, error) { if snapshotID == "latest" { - id, err := FindLatestSnapshot(ctx, be, loader, paths, tags, hosts, timeStampLimit) + id, err := findLatestSnapshot(ctx, be, loader, paths, tags, hosts, timeStampLimit) if err == ErrNoSnapshotFound { err = fmt.Errorf("snapshot filter (Paths:%v Tags:%v Hosts:%v): %w", paths, tags, hosts, err) } @@ -124,7 +124,7 @@ func FindFilteredSnapshots(ctx context.Context, be Lister, loader LoaderUnpacked usedFilter = true - id, err = FindLatestSnapshot(ctx, be, loader, paths, tags, hosts, nil) + id, err = findLatestSnapshot(ctx, be, loader, paths, tags, hosts, nil) if err == ErrNoSnapshotFound { err = errors.Errorf("no snapshot matched given filter (Paths:%v Tags:%v Hosts:%v)", paths, tags, hosts) } diff --git a/internal/restic/snapshot_find_test.go b/internal/restic/snapshot_find_test.go index 534eb456d..e43c52c6b 100644 --- a/internal/restic/snapshot_find_test.go +++ b/internal/restic/snapshot_find_test.go @@ -16,7 +16,7 @@ func TestFindLatestSnapshot(t *testing.T) { restic.TestCreateSnapshot(t, repo, parseTimeUTC("2017-07-07 07:07:07"), 1, 0) latestSnapshot := restic.TestCreateSnapshot(t, repo, parseTimeUTC("2019-09-09 09:09:09"), 1, 0) - id, err := restic.FindLatestSnapshot(context.TODO(), repo.Backend(), repo, []string{}, []restic.TagList{}, []string{"foo"}, nil) + id, err := restic.FindFilteredSnapshot(context.TODO(), repo.Backend(), repo, []string{"foo"}, []restic.TagList{}, []string{}, nil, "latest") if err != nil { t.Fatalf("FindLatestSnapshot returned error: %v", err) } @@ -36,7 +36,7 @@ func TestFindLatestSnapshotWithMaxTimestamp(t *testing.T) { maxTimestamp := parseTimeUTC("2018-08-08 08:08:08") - id, err := restic.FindLatestSnapshot(context.TODO(), repo.Backend(), repo, []string{}, []restic.TagList{}, []string{"foo"}, &maxTimestamp) + id, err := restic.FindFilteredSnapshot(context.TODO(), repo.Backend(), repo, []string{"foo"}, []restic.TagList{}, []string{}, &maxTimestamp, "latest") if err != nil { t.Fatalf("FindLatestSnapshot returned error: %v", err) }