Browse Source

[webdav] status code 500 if internal error from filer (#5865)

pull/5868/head
Konstantin Lebedev 5 months ago
committed by GitHub
parent
commit
3e6ca6e706
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 23
      weed/server/webdav_server.go

23
weed/server/webdav_server.go

@ -99,6 +99,7 @@ type FileInfo struct {
modifiedTime time.Time
etag string
isDirectory bool
err error
}
func (fi *FileInfo) Name() string { return fi.name }
@ -109,6 +110,9 @@ func (fi *FileInfo) IsDir() bool { return fi.isDirectory }
func (fi *FileInfo) Sys() interface{} { return nil }
func (fi *FileInfo) ETag(ctx context.Context) (string, error) {
if fi.err != nil {
return "", fi.err
}
return fi.etag, nil
}
@ -269,7 +273,10 @@ func (fs *WebDavFileSystem) OpenFile(ctx context.Context, fullFilePath string, f
fi, err := fs.stat(ctx, fullFilePath)
if err != nil {
return nil, os.ErrNotExist
if err == os.ErrNotExist {
return nil, err
}
return &WebDavFile{fs: fs}, nil
}
if !strings.HasSuffix(fullFilePath, "/") && fi.IsDir() {
fullFilePath += "/"
@ -365,11 +372,15 @@ func (fs *WebDavFileSystem) stat(ctx context.Context, fullFilePath string) (os.F
var fi FileInfo
entry, err := filer_pb.GetEntry(fs, fullpath)
if entry == nil {
if err != nil {
if err == filer_pb.ErrNotFound {
return nil, os.ErrNotExist
}
if err != nil {
return nil, err
fi.err = err
return &fi, nil
}
if entry == nil {
return nil, os.ErrNotExist
}
fi.size = int64(filer.FileSize(entry))
fi.name = string(fullpath)
@ -514,7 +525,9 @@ func (f *WebDavFile) Write(buf []byte) (int, error) {
func (f *WebDavFile) Close() error {
glog.V(2).Infof("WebDavFileSystem.Close %v", f.name)
if f.bufWriter == nil {
return nil
}
err := f.bufWriter.Close()
if f.entry != nil {

Loading…
Cancel
Save