Skip to content

Commit

Permalink
Release lock early early
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Jun 28, 2023
1 parent 171f56d commit f2c39e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/storage/utils/decomposedfs/metadata/messagepack_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ func (b MessagePackBackend) loadAttributes(path string, source io.Reader) (map[s
}

metaPath := b.MetadataPath(path)
var msgBytes []byte

if source == nil {
source, err = lockedfile.Open(metaPath)
// // No cached entry found. Read from storage and store in cache
source, err = lockedfile.Open(metaPath)
if err != nil {
if os.IsNotExist(err) {
// some of the caller rely on ENOTEXISTS to be returned when the
Expand All @@ -210,10 +212,11 @@ func (b MessagePackBackend) loadAttributes(path string, source io.Reader) (map[s
return attribs, nil // no attributes set yet
}
}
defer source.(*lockedfile.File).Close()
msgBytes, err = io.ReadAll(source)
source.(*lockedfile.File).Close()
} else {
msgBytes, err = io.ReadAll(source)
}

msgBytes, err := io.ReadAll(source)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit f2c39e4

Please sign in to comment.