Overwrite existing dest when copying symlink and preserve link target

This commit is contained in:
Adrian Duong 2018-11-17 23:06:34 -08:00
parent 3367268ef9
commit f23cc32c42
1 changed files with 6 additions and 2 deletions

View File

@ -501,8 +501,12 @@ func CopySymlink(src, dest string) error {
if err != nil { if err != nil {
return err return err
} }
linkDst := filepath.Join(dest, link) if FilepathExists(dest) {
return os.Symlink(linkDst, dest) if err := os.RemoveAll(dest); err != nil {
return err
}
}
return os.Symlink(link, dest)
} }
// CopyFile copies the file at src to dest // CopyFile copies the file at src to dest