Skip to content

Commit

Permalink
Improve Logging When Data File Does Not Exist (#2586)
Browse files Browse the repository at this point in the history
FAB-18469

Signed-off-by: Julian Castrence <[email protected]>

Co-authored-by: Julian Castrence <[email protected]>
  • Loading branch information
jcastrence and jrc-ibm authored May 14, 2021
1 parent dbf7eb1 commit 13bcf3f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/ledger/kvledger/txmgmt/privacyenabledstate/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,17 @@ type snapshotReader struct {
cursor *cursor
}

// If the passed in file name does not exist a nil response is returned
func newSnapshotReader(dir, dataFileName, metadataFileName string) (*snapshotReader, error) {
dataFilePath := filepath.Join(dir, dataFileName)
metadataFilePath := filepath.Join(dir, metadataFileName)
exist, _, err := fileutil.FileExists(dataFilePath)
if err != nil || !exist {
return nil, err
if err != nil {
return nil, errors.WithMessage(err, "error while checking if data file exists")
}
if !exist {
logger.Infow("Data file does not exist. Nothing to be done.", "filepath", dataFilePath)
return nil, nil
}

var dataFile, metadataFile *snapshot.FileReader
Expand Down

0 comments on commit 13bcf3f

Please sign in to comment.