mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2024-04-21 12:32:08 +00:00
feature (plg_backend_local): better error handling
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
@@ -10,5 +12,9 @@ func SafeOsOpenFile(path string, flag int, perm os.FileMode) (*os.File, error) {
|
||||
Log.Debug("common::files safeOsOpenFile err[%s] path[%s]", err.Error(), path)
|
||||
return nil, ErrFilesystemError
|
||||
}
|
||||
return os.OpenFile(path, flag|syscall.O_NOFOLLOW, perm)
|
||||
f, err := os.OpenFile(path, flag|syscall.O_NOFOLLOW, perm)
|
||||
if err != nil && errors.Is(err, fs.ErrNotExist) {
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
return f, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user