1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

v.vcache: fix a panic due to a race on creating folders in ~/.vmodules/cache/XY

This commit is contained in:
Delyan Angelov 2023-01-30 19:00:00 +02:00
parent 9c78e3c289
commit 62f7e56a18
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -89,7 +89,13 @@ pub fn (mut cm CacheManager) key2cpath(key string) string {
cprefix_folder := os.join_path(cm.basepath, prefix)
cpath = os.join_path(cprefix_folder, khash)
if !os.is_dir(cprefix_folder) {
os.mkdir_all(cprefix_folder) or { panic(err) }
os.mkdir_all(cprefix_folder) or {
// The error here may be due to a race with another independent V process, that has already created the same folder.
// If that is the case, so be it - just reuse the folder ¯\_(ツ)_/¯ ...
if !os.is_dir(cprefix_folder) {
panic(err)
}
}
}
dlog(@FN, 'new hk')
dlog(@FN, ' key: ${key}')