Skip to content

Commit

Permalink
put mutex on Mkdir code
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed Jun 7, 2024
1 parent 04863bc commit cd85149
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions check/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ import (
"time"
)

var mu sync.Mutex

// getCachePath returns OS specific absolute path to filename that is used to
// caching data from the Internet. On Unix it will be $HOME/.checkip/<filename>
func getCachePath(filename string) (string, error) {
mu.Lock()
defer mu.Unlock()

usr, err := user.Current()
if err != nil {
return "", err
Expand All @@ -35,8 +40,6 @@ func getCachePath(filename string) (string, error) {
return filepath.Join(dir, filename), nil
}

var mu sync.Mutex

// updateFile updates file from url if the file is older than a week. If file
// does not exist it downloads and creates it. compressFmt is the compression
// format of the file to download; gz or tgz. Empty string means no compression.
Expand Down

0 comments on commit cd85149

Please sign in to comment.