fix(install): release file lock before return

This commit is contained in:
Jan De Dobbeleer 2024-07-09 22:22:32 +02:00 committed by Jan De Dobbeleer
parent b8180b197c
commit d9c2fbb784

View file

@ -32,16 +32,14 @@ func install(tag string) error {
return err
}
defer fp.Close()
_, err = io.Copy(fp, bytes.NewReader(data))
// windows will have a lock when we do not close the file
fp.Close()
if err != nil {
return err
}
// windows will have a lock when we do not close the file
fp.Close()
oldPath := filepath.Join(targetDir, fmt.Sprintf(".%s.old", fileName))
_ = os.Remove(oldPath)