Skip to content

Commit 0523a92

Browse files
committed
backup: move ContainsManifest to backupInfo package
Epic: none Release note: none
1 parent 3317b2c commit 0523a92

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

pkg/backup/backupdest/backup_destination.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,6 @@ const (
5454
// will contain one.
5555
var backupPathRE = regexp.MustCompile("^/?[^\\/]+/[^\\/]+/[^\\/]+/" + backupbase.DeprecatedBackupManifestName + "$")
5656

57-
// TODO(adityamaru): Move this to the soon to be `backupinfo` package.
58-
func containsManifest(ctx context.Context, exportStore cloud.ExternalStorage) (bool, error) {
59-
r, _, err := exportStore.ReadFile(ctx, backupbase.DeprecatedBackupManifestName, cloud.ReadOptions{NoFileSize: true})
60-
if err != nil {
61-
if errors.Is(err, cloud.ErrFileDoesNotExist) {
62-
return false, nil
63-
}
64-
return false, err
65-
}
66-
r.Close(ctx)
67-
return true, nil
68-
}
69-
7057
// ResolvedDestination encapsulates information that is populated while
7158
// resolving the destination of a backup.
7259
type ResolvedDestination struct {
@@ -148,7 +135,7 @@ func ResolveDest(
148135
return ResolvedDestination{}, err
149136
}
150137
defer defaultStore.Close()
151-
exists, err := containsManifest(ctx, defaultStore)
138+
exists, err := backupinfo.ContainsManifest(ctx, defaultStore)
152139
if err != nil {
153140
return ResolvedDestination{}, err
154141
}

pkg/backup/backupinfo/manifest_handling.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ func ReadBackupManifestFromStore(
168168
return manifest, memSize, nil
169169
}
170170

171+
func ContainsManifest(ctx context.Context, exportStore cloud.ExternalStorage) (bool, error) {
172+
r, _, err := exportStore.ReadFile(ctx, backupbase.DeprecatedBackupManifestName, cloud.ReadOptions{NoFileSize: true})
173+
if err != nil {
174+
if errors.Is(err, cloud.ErrFileDoesNotExist) {
175+
return false, nil
176+
}
177+
return false, err
178+
}
179+
r.Close(ctx)
180+
return true, nil
181+
}
182+
171183
// compressData compresses data buffer and returns compressed
172184
// bytes (i.e. gzip format).
173185
func compressData(descBuf []byte) ([]byte, error) {

0 commit comments

Comments
 (0)