-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4257 from snyk/fix/HMMR-626
fix: align tmp and cache dir
- Loading branch information
Showing
7 changed files
with
91 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package utils | ||
|
||
import ( | ||
"os" | ||
"path" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// The directory structure used to cache things into | ||
// - Base cache directory (user definable, default depends on OS, exmple: /Users/username/Library/Caches/snyk/) | ||
// |- Version cache directory (example: /Users/username/Library/Caches/snyk/1.1075.0/) | ||
// |- Temp directory (example: /Users/username/Library/Caches/snyk/1.1075.0/tmp/) | ||
|
||
func GetTemporaryDirectory(baseCacheDirectory string, versionNumber string) string { | ||
return path.Join(GetVersionCacheDirectory(baseCacheDirectory, versionNumber), "tmp") | ||
} | ||
|
||
func GetVersionCacheDirectory(baseCacheDirectory string, versionNumber string) string { | ||
return path.Join(baseCacheDirectory, versionNumber) | ||
} | ||
|
||
func CreateAllDirectories(baseCacheDirectory string, versionNumber string) error { | ||
directoryList := []string{ | ||
GetTemporaryDirectory(baseCacheDirectory, versionNumber), | ||
} | ||
|
||
for _, dir := range directoryList { | ||
err := os.MkdirAll(dir, 0755) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to create all directories.") | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters