Skip to content

Commit

Permalink
fix: adjust closing file to make world cli run on windows (#67)
Browse files Browse the repository at this point in the history
Closes: WORLD-1149

## Overview

When trying to run world cli on windows, there's an issue when exec `world create`. This PR is adjusting the code for windows OS.

## Brief Changelog

- Adjust file close to avoid Access Denied

## Testing and Verifying

Manually tested on windows without using WSL
  • Loading branch information
zulkhair committed Jun 10, 2024
1 parent 5fd07ae commit 8685e76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/teacmd/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ func downloadAndUnzip(url string, targetDir string) error {
if err != nil {
return err
}
defer file.Close()

_, err = io.Copy(file, resp.Body)
if err != nil {
return err
}
file.Close()

if err = unzipFile(tmpZipFileName, targetDir); err != nil {
return err
Expand Down Expand Up @@ -227,12 +227,12 @@ func unzipFile(filename string, targetDir string) error {
if err != nil {
return err
}
defer dst.Close()

_, err = io.Copy(dst, src) //nolint:gosec // zip file is from us
if err != nil {
return err
}
dst.Close()
}

if err = os.Rename(filepath.Join(filepath.Dir(targetDir), originalDir), targetDir); err != nil {
Expand Down

0 comments on commit 8685e76

Please # to comment.