Skip to content

Commit

Permalink
Fixes dapr#2374
Browse files Browse the repository at this point in the history
- Close file descriptor after reading a file
- Report a more specific error if the file doesn't exist

Signed-off-by: ItalyPaleAle <[email protected]>
  • Loading branch information
ItalyPaleAle committed Jan 18, 2023
1 parent 4ded1e7 commit d948078
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bindings/localstorage/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,12 @@ func (ls *LocalStorage) get(filename string, req *bindings.InvokeRequest) (*bind

f, err := os.Open(absPath)
if err != nil {
if os.IsNotExist(err) {
return nil, fmt.Errorf("file not found: %s", absPath)
}
return nil, fmt.Errorf("error opening path %s: %w", absPath, err)
}
defer f.Close()

b, err := io.ReadAll(f)
if err != nil {
Expand Down

0 comments on commit d948078

Please sign in to comment.