Skip to content

Commit affb71f

Browse files
committed
backup: use ContainsManifest in CheckForPreviousBackups
Epic: none Release note: none
1 parent 0523a92 commit affb71f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pkg/backup/backupinfo/manifest_handling.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,19 +1307,17 @@ func CheckForPreviousBackup(
13071307
defer defaultStore.Close()
13081308

13091309
redactedURI := backuputils.RedactURIForErrorMessage(defaultURI)
1310-
r, _, err := defaultStore.ReadFile(ctx, backupbase.DeprecatedBackupManifestName, cloud.ReadOptions{NoFileSize: true})
1311-
if err == nil {
1312-
r.Close(ctx)
1313-
return pgerror.Newf(pgcode.FileAlreadyExists,
1314-
"%s already contains a %s file",
1315-
redactedURI, backupbase.DeprecatedBackupManifestName)
1316-
}
1317-
1318-
if !errors.Is(err, cloud.ErrFileDoesNotExist) {
1310+
exists, err := ContainsManifest(ctx, defaultStore)
1311+
if err != nil {
13191312
return errors.Wrapf(err,
13201313
"%s returned an unexpected error when checking for the existence of %s file",
13211314
redactedURI, backupbase.DeprecatedBackupManifestName)
13221315
}
1316+
if exists {
1317+
return pgerror.Newf(pgcode.FileAlreadyExists,
1318+
"%s already contains a %s file",
1319+
redactedURI, backupbase.DeprecatedBackupManifestName)
1320+
}
13231321

13241322
// Check for the presence of a BACKUP-LOCK file with a job ID different from
13251323
// that of our job.

0 commit comments

Comments
 (0)