filer: set file name when uploading to a directory

fix https://github.com/chrislusf/seaweedfs/issues/1005
This commit is contained in:
Chris Lu 2019-07-11 04:20:03 -07:00
parent 61b7a650f4
commit 1d1b355f9e

View file

@ -150,15 +150,15 @@ func (fs *FilerServer) updateFilerStore(ctx context.Context, r *http.Request, w
}() }()
path := r.URL.Path path := r.URL.Path
if strings.HasSuffix(path, "/") {
if ret.Name != "" {
path += ret.Name
}
}
existingEntry, err := fs.filer.FindEntry(ctx, filer2.FullPath(path)) existingEntry, err := fs.filer.FindEntry(ctx, filer2.FullPath(path))
crTime := time.Now() crTime := time.Now()
if err == nil && existingEntry != nil { if err == nil && existingEntry != nil {
// glog.V(4).Infof("existing %s => %+v", path, existingEntry) crTime = existingEntry.Crtime
if existingEntry.IsDirectory() {
path += "/" + ret.Name
} else {
crTime = existingEntry.Crtime
}
} }
entry := &filer2.Entry{ entry := &filer2.Entry{
FullPath: filer2.FullPath(path), FullPath: filer2.FullPath(path),