diff options
| author | zzq09494 <zzq09494@ly.com> | 2022-03-17 10:18:23 +0800 |
|---|---|---|
| committer | zzq09494 <zzq09494@ly.com> | 2022-03-17 10:18:23 +0800 |
| commit | a93c4947bae0dcf4a276aedf9f84785ccf83f27a (patch) | |
| tree | 0ea6e95316df79ed3917a452885125d7d0ea5acd /weed/filer | |
| parent | 2aa9d9f84ac466e348821066f6332a8a5b777d47 (diff) | |
| download | seaweedfs-a93c4947bae0dcf4a276aedf9f84785ccf83f27a.tar.xz seaweedfs-a93c4947bae0dcf4a276aedf9f84785ccf83f27a.zip | |
filer: support uploading file without needEnsureParentDir
Diffstat (limited to 'weed/filer')
| -rw-r--r-- | weed/filer/filer.go | 10 | ||||
| -rw-r--r-- | weed/filer/filer_notify_append.go | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/weed/filer/filer.go b/weed/filer/filer.go index 0f34adb4d..41f91ce9a 100644 --- a/weed/filer/filer.go +++ b/weed/filer/filer.go @@ -151,7 +151,7 @@ func (f *Filer) RollbackTransaction(ctx context.Context) error { return f.Store.RollbackTransaction(ctx) } -func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool, isFromOtherCluster bool, signatures []int32) error { +func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool, isFromOtherCluster bool, signatures []int32,needEnsureParentDir bool) error { if string(entry.FullPath) == "/" { return nil @@ -169,9 +169,11 @@ func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool, isFr if oldEntry == nil { - dirParts := strings.Split(string(entry.FullPath), "/") - if err := f.ensureParentDirecotryEntry(ctx, entry, dirParts, len(dirParts)-1, isFromOtherCluster); err != nil { - return err + if needEnsureParentDir { + dirParts := strings.Split(string(entry.FullPath), "/") + if err := f.ensureParentDirecotryEntry(ctx, entry, dirParts, len(dirParts)-1, isFromOtherCluster); err != nil { + return err + } } glog.V(4).Infof("InsertEntry %s: new entry: %v", entry.FullPath, entry.Name()) diff --git a/weed/filer/filer_notify_append.go b/weed/filer/filer_notify_append.go index e30ef4e54..0df940082 100644 --- a/weed/filer/filer_notify_append.go +++ b/weed/filer/filer_notify_append.go @@ -43,7 +43,7 @@ func (f *Filer) appendToFile(targetFile string, data []byte) error { entry.Chunks = append(entry.Chunks, uploadResult.ToPbFileChunk(assignResult.Fid, offset)) // update the entry - err = f.CreateEntry(context.Background(), entry, false, false, nil) + err = f.CreateEntry(context.Background(), entry, false, false, nil,true) return err } |
