diff --git a/server/webdav/file.go b/server/webdav/file.go index 5c8ddb2d..995cc26b 100644 --- a/server/webdav/file.go +++ b/server/webdav/file.go @@ -24,8 +24,13 @@ import ( type FileSystem struct{} +var upFileMap = make(map[string]*model.File) + func (fs *FileSystem) File(rawPath string) (*model.File, error) { rawPath = utils.ParsePath(rawPath) + if f, ok := upFileMap[rawPath]; ok { + return f, nil + } if model.AccountsCount() > 1 && rawPath == "/" { now := time.Now() return &model.File{ @@ -170,7 +175,10 @@ func (fs *FileSystem) Upload(ctx context.Context, r *http.Request, rawPath strin } if fileSize == 0 { // 如果文件大小为0,默认成功 + upFileMap[rawPath] = fi return fi, nil + } else { + delete(upFileMap, rawPath) } fileData := model.FileStream{ MIMEType: r.Header.Get("Content-Type"),