Skip to content

Commit

Permalink
fix(CLI): Pull should not crash on empty files (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
jablan committed Jul 15, 2024
1 parent bdbeeac commit 3e3b33c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions clients/cli/cmd/internal/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,17 @@ func (target *Target) downloadSynchronously(client *phrase.APIClient, localeFile
}

func copyToDestination(file *os.File, path string) error {
var data []byte
data, err := io.ReadAll(file)
destFile, err := os.Create(path)
if err != nil {
return err
}
file.Close()
os.Remove(file.Name())

err = os.WriteFile(path, data, 0644)
return err
defer destFile.Close()
if file != nil {
defer file.Close()
_, err = io.Copy(destFile, file)
return err
}
return nil
}

func downloadExportedLocale(url string, localName string) error {
Expand Down

0 comments on commit 3e3b33c

Please sign in to comment.