Skip to content

Commit

Permalink
Fix: make rename replace old dir (#1237)
Browse files Browse the repository at this point in the history
* Fix: make rename replace old dir
Co-authored-by: lizhixin.lzx <lizhixin.lzx@alibaba-inc.com>
  • Loading branch information
LaurenceLiZhixin authored Feb 16, 2023
1 parent 7488bda commit 9462311
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/yurthub/util/fs/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ func (fs *FileSystemOperator) Rename(oldPath string, newPath string) error {
if !IfExists(oldPath) {
return ErrNotExists
}

if ok, err := IsDir(newPath); ok && err == nil {
if err := fs.DeleteDir(newPath); err != nil {
return err
}
}

if filepath.Dir(oldPath) != filepath.Dir(newPath) {
return ErrInvalidPath
}
Expand Down

0 comments on commit 9462311

Please # to comment.