Skip to content

Commit

Permalink
fixbug: when move file, target file is not exists
Browse files Browse the repository at this point in the history
Signed-off-by: tiny.x <185120555@qq.com>
  • Loading branch information
tiny-x committed Aug 24, 2020
1 parent e9d568c commit 6260f32
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exec/bin/file/movefile/movefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func startMoveFile(filepath, target string, force, autoCreateDir bool) {
if autoCreateDir && !util.IsExist(target) {
response = cl.Run(ctx, "mkdir", fmt.Sprintf(`-p %s`, target))
}
if !util.IsDir(target) {
bin.PrintErrAndExit(fmt.Sprintf("the [%s] target file is not exists", target))
return
}
if force {
response = cl.Run(ctx, "mv", fmt.Sprintf(`-f "%s" "%s"`, filepath, target))
} else {
Expand Down

0 comments on commit 6260f32

Please sign in to comment.