Skip to content

Commit

Permalink
Removed Errorneous Continue when Extracting Gz (#1117)
Browse files Browse the repository at this point in the history
* removed errorneous continue

* found a cleaner expression to test if file exists

* add more user-friendly error
  • Loading branch information
rpl-ffl committed Jun 6, 2024
1 parent f3e22f4 commit 1b37925
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions utildb/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,8 @@ func extractTarGz(tarGzFile, outputFolder string) error {

// Make sure that output file does not overwrite existing files
_, err = os.Stat(targetPath)
if err != nil && errors.Is(err, os.ErrNotExist) { // check if not exist is clearer than check if exists
continue
} else {
return fmt.Errorf("Tarfile is attempting to overwrite existing file: %s", targetPath)
if err == nil || os.IsExist(err) {
return fmt.Errorf("Tarfile is attempting to overwrite existing file. This may have happened due to previous failed attempt to extract the file - consider removing the folder %s", targetPath)
}

// Check if it's a directory
Expand Down

0 comments on commit 1b37925

Please sign in to comment.