mirror of
https://github.com/caddyserver/caddy.git
synced 2026-01-17 01:30:34 +00:00
chore: check against errors of io/fs instead of os (#6011)
* chore: replace `os.ErrNotExist` with `fs.ErrNotExist` * check against permission error from `io/fs` package
This commit is contained in:
committed by
GitHub
parent
b568a10dd4
commit
787f6b257f
@@ -506,10 +506,10 @@ func (fsrv *FileServer) openFile(filename string, w http.ResponseWriter) (fs.Fil
|
||||
file, err := fsrv.fileSystem.Open(filename)
|
||||
if err != nil {
|
||||
err = fsrv.mapDirOpenError(err, filename)
|
||||
if os.IsNotExist(err) {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
fsrv.logger.Debug("file not found", zap.String("filename", filename), zap.Error(err))
|
||||
return nil, caddyhttp.Error(http.StatusNotFound, err)
|
||||
} else if os.IsPermission(err) {
|
||||
} else if errors.Is(err, fs.ErrPermission) {
|
||||
fsrv.logger.Debug("permission denied", zap.String("filename", filename), zap.Error(err))
|
||||
return nil, caddyhttp.Error(http.StatusForbidden, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user