mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix: return etag with md5 in webdav responses (#5158)
This commit is contained in:
parent
d3688938d9
commit
b832ddd1ef
|
@ -96,6 +96,7 @@ type FileInfo struct {
|
|||
size int64
|
||||
mode os.FileMode
|
||||
modifiedTime time.Time
|
||||
etag string
|
||||
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) Sys() interface{} { return nil }
|
||||
|
||||
func (fi *FileInfo) ETag(ctx context.Context) (string, error) {
|
||||
return fi.etag, nil
|
||||
}
|
||||
|
||||
type WebDavFile struct {
|
||||
fs *WebDavFileSystem
|
||||
name string
|
||||
|
@ -369,6 +374,7 @@ func (fs *WebDavFileSystem) stat(ctx context.Context, fullFilePath string) (os.F
|
|||
fi.name = string(fullpath)
|
||||
fi.mode = os.FileMode(entry.Attributes.FileMode)
|
||||
fi.modifiedTime = time.Unix(entry.Attributes.Mtime, 0)
|
||||
fi.etag = filer.ETag(entry)
|
||||
fi.isDirectory = entry.IsDirectory
|
||||
|
||||
if fi.name == "/" {
|
||||
|
|
|
@ -95,3 +95,11 @@ func (w wrappedFileInfo) Name() string {
|
|||
name := w.FileInfo.Name()
|
||||
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…
Reference in a new issue