Browse Source

fix: return etag with md5 in webdav responses (#5158)

pull/5161/head
Konstantin Lebedev 12 months ago
committed by GitHub
parent
commit
b832ddd1ef
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      weed/server/webdav_server.go
  2. 8
      weed/server/wrapped_webdav_fs.go

6
weed/server/webdav_server.go

@ -96,6 +96,7 @@ type FileInfo struct {
size int64 size int64
mode os.FileMode mode os.FileMode
modifiedTime time.Time modifiedTime time.Time
etag string
isDirectory bool isDirectory bool
} }
@ -106,6 +107,10 @@ func (fi *FileInfo) ModTime() time.Time { return fi.modifiedTime }
func (fi *FileInfo) IsDir() bool { return fi.isDirectory } func (fi *FileInfo) IsDir() bool { return fi.isDirectory }
func (fi *FileInfo) Sys() interface{} { return nil } func (fi *FileInfo) Sys() interface{} { return nil }
func (fi *FileInfo) ETag(ctx context.Context) (string, error) {
return fi.etag, nil
}
type WebDavFile struct { type WebDavFile struct {
fs *WebDavFileSystem fs *WebDavFileSystem
name string name string
@ -369,6 +374,7 @@ func (fs *WebDavFileSystem) stat(ctx context.Context, fullFilePath string) (os.F
fi.name = string(fullpath) fi.name = string(fullpath)
fi.mode = os.FileMode(entry.Attributes.FileMode) fi.mode = os.FileMode(entry.Attributes.FileMode)
fi.modifiedTime = time.Unix(entry.Attributes.Mtime, 0) fi.modifiedTime = time.Unix(entry.Attributes.Mtime, 0)
fi.etag = filer.ETag(entry)
fi.isDirectory = entry.IsDirectory fi.isDirectory = entry.IsDirectory
if fi.name == "/" { if fi.name == "/" {

8
weed/server/wrapped_webdav_fs.go

@ -95,3 +95,11 @@ func (w wrappedFileInfo) Name() string {
name := w.FileInfo.Name() name := w.FileInfo.Name()
return strings.TrimPrefix(name, *w.subFolder) return strings.TrimPrefix(name, *w.subFolder)
} }
func (w wrappedFileInfo) ETag(ctx context.Context) (string, error) {
etag, _ := w.FileInfo.(webdav.ETager).ETag(ctx)
if len(etag) == 0 {
return etag, webdav.ErrNotImplemented
}
return etag, nil
}
Loading…
Cancel
Save