Skip to content

Commit

Permalink
Defer only for --single-data-file
Browse files Browse the repository at this point in the history
  • Loading branch information
bandetto committed Jun 26, 2024
1 parent e1afa50 commit b77615b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions helper/restore_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,15 @@ func doRestoreAgent() error {

filename := replaceContentInFilename(*dataFile, contentToRestore)
readers[contentToRestore], err = getRestoreDataReader(filename, segmentTOC[contentToRestore], oidList)
if err != nil {
if readers[contentToRestore] != nil {
if readers[contentToRestore] != nil {
// There will be only one reader, so we defer the cleanup
// instead of doing it every iteration.
defer func() {
readers[contentToRestore].logPlugin()
}
readers[contentToRestore].waitForPlugin()
}()
}
if err != nil {
logError(fmt.Sprintf("Error encountered getting restore data reader for single data file: %v", err))
return err
}
Expand Down Expand Up @@ -319,9 +324,7 @@ func doRestoreAgent() error {
err = readers[contentToRestore].positionReader(start[contentToRestore]-lastByte[contentToRestore], oid)
if err != nil {
logError(fmt.Sprintf("Oid %d: Error reading from pipe: %v", oid, err))
if readers[contentToRestore] != nil {
readers[contentToRestore].logPlugin()
}
readers[contentToRestore].logPlugin()
return err
}
}
Expand Down

0 comments on commit b77615b

Please sign in to comment.