diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-11-29 00:00:56 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-11-29 00:00:56 -0800 |
| commit | ceca078acb8607f5d3252356617cf630ff6b4be8 (patch) | |
| tree | cf34f511f81d9a450ab5e158666e0ad6a46cab0a | |
| parent | 021f5d689b78f19152fdec86a6f88d8f36f3c659 (diff) | |
| download | seaweedfs-ceca078acb8607f5d3252356617cf630ff6b4be8.tar.xz seaweedfs-ceca078acb8607f5d3252356617cf630ff6b4be8.zip | |
avoid overwriting file or directory
fix https://github.com/chrislusf/seaweedfs/issues/777
| -rw-r--r-- | weed/filer2/filer.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/weed/filer2/filer.go b/weed/filer2/filer.go index 659054d86..0dde08d04 100644 --- a/weed/filer2/filer.go +++ b/weed/filer2/filer.go @@ -132,6 +132,12 @@ func (f *Filer) CreateEntry(entry *Entry) error { return fmt.Errorf("insert entry %s: %v", entry.FullPath, err) } } else { + if oldEntry.IsDirectory() && !entry.IsDirectory() { + return fmt.Errorf("existing %s is a directory", entry.FullPath) + } + if !oldEntry.IsDirectory() && entry.IsDirectory() { + return fmt.Errorf("existing %s is a file", entry.FullPath) + } if err := f.store.UpdateEntry(entry); err != nil { return fmt.Errorf("update entry %s: %v", entry.FullPath, err) } |
