Skip to content

Commit

Permalink
remove existing files to overwrite during sync
Browse files Browse the repository at this point in the history
  • Loading branch information
VJftw committed Nov 28, 2024
1 parent 5235afa commit 0380925
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/please/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ func CopyFile(src string, dest string) error {
return err
}

if _, err := os.Stat(dest); err == nil {
// file exists, ensure removal is possible then remove.
if err := os.Chmod(dest, 0664); err != nil {
return fmt.Errorf("could not delete file, could not make file writeable: %w", err)
}
if err := os.Remove(dest); err != nil {
return fmt.Errorf("could not delete file: %w", err)
}
}

destination, err := os.Create(dest)
if err != nil {
return fmt.Errorf("could not create '%s': %w", dest, err)
Expand Down

0 comments on commit 0380925

Please sign in to comment.