Skip to content

Commit

Permalink
Fix: file lock order
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Sep 19, 2022
1 parent 6d38172 commit ede63ef
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/console_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ func codePage(types string) string {
}

func (c *console) UnloadEmbeddedDeps() (string, error) {
flock := fslock.New(filepath.Join(os.TempDir(), "pty_winpty_lock"))
if err := flock.LockWithTimeout(time.Second * 3); err != nil {
return "", err
}
defer flock.Unlock()

dllDir := filepath.Join(os.TempDir(), "pty_winpty")

if err := os.MkdirAll(dllDir, os.ModePerm); err != nil {
return "", err
}
Expand All @@ -130,11 +137,7 @@ func releases(f *bytes.Reader, targetPath string) error {
if err != nil {
return err
}
flock := fslock.New(targetPath + `lock`)
if err := flock.LockWithTimeout(time.Second * 3); err != nil {
return err
}
defer flock.Unlock()

for _, f := range zipReader.File {
fpath := filepath.Join(targetPath, f.Name)
info, statErr := os.Stat(fpath)
Expand Down Expand Up @@ -163,7 +166,7 @@ func releases(f *bytes.Reader, targetPath string) error {
return err
}
}
return err
return nil
}

func (c *console) StdIn() io.Writer {
Expand Down

0 comments on commit ede63ef

Please sign in to comment.