Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Jan 14, 2025
1 parent bc0e049 commit beb75c1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions content/file/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ func extractTarDirectory(dirPath, dirName string, r io.Reader, buf []byte) error
if err != nil {
return err
}
if _, err := os.Lstat(filePath); err == nil {
// link already exists, remove it first
if err = os.Symlink(target, filePath); err != nil {
if !os.IsExist(err) {
return err
}
// link already exists, remove the old one and try again
if err := os.Remove(filePath); err != nil {
return err
}
err = os.Symlink(target, filePath)
}
err = os.Symlink(target, filePath)
default:
continue // Non-regular files are skipped
}
Expand Down

0 comments on commit beb75c1

Please sign in to comment.