6
6
#include " node_internals.h"
7
7
#include " node_version.h"
8
8
#include " path.h"
9
+ #include " util.h"
9
10
#include " zlib.h"
10
11
11
12
#ifdef NODE_IMPLEMENTS_POSIX_CREDENTIALS
@@ -225,14 +226,11 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert(
225
226
compiler_cache_store_.emplace (key, std::make_unique<CompileCacheEntry>());
226
227
auto * result = emplaced.first ->second .get ();
227
228
228
- std::u8string cache_filename_u8 =
229
- (compile_cache_dir_ / Uint32ToHex (key)).u8string ();
230
229
result->code_hash = code_hash;
231
230
result->code_size = code_utf8.length ();
232
231
result->cache_key = key;
233
232
result->cache_filename =
234
- std::string (cache_filename_u8.begin (), cache_filename_u8.end ()) +
235
- " .cache" ;
233
+ compile_cache_dir_ + kPathSeparator + Uint32ToHex (key);
236
234
result->source_filename = filename_utf8.ToString ();
237
235
result->cache = nullptr ;
238
236
result->type = type;
@@ -452,43 +450,40 @@ CompileCacheEnableResult CompileCacheHandler::Enable(Environment* env,
452
450
const std::string& dir) {
453
451
std::string cache_tag = GetCacheVersionTag ();
454
452
std::string absolute_cache_dir_base = PathResolve (env, {dir});
455
- std::filesystem::path cache_dir_with_tag =
456
- std::filesystem::path (absolute_cache_dir_base) / cache_tag;
457
- std::u8string cache_dir_with_tag_u8 = cache_dir_with_tag.u8string ();
458
- std::string cache_dir_with_tag_str (cache_dir_with_tag_u8.begin (),
459
- cache_dir_with_tag_u8.end ());
453
+ std::string cache_dir_with_tag =
454
+ absolute_cache_dir_base + kPathSeparator + cache_tag;
460
455
CompileCacheEnableResult result;
461
456
Debug (" [compile cache] resolved path %s + %s -> %s\n " ,
462
457
dir,
463
458
cache_tag,
464
- cache_dir_with_tag_str );
459
+ cache_dir_with_tag );
465
460
466
461
if (UNLIKELY (!env->permission ()->is_granted (
467
462
env,
468
463
permission::PermissionScope::kFileSystemWrite ,
469
- cache_dir_with_tag_str ))) {
464
+ cache_dir_with_tag ))) {
470
465
result.message = " Skipping compile cache because write permission for " +
471
- cache_dir_with_tag_str + " is not granted" ;
466
+ cache_dir_with_tag + " is not granted" ;
472
467
result.status = CompileCacheEnableStatus::FAILED;
473
468
return result;
474
469
}
475
470
476
471
if (UNLIKELY (!env->permission ()->is_granted (
477
472
env,
478
473
permission::PermissionScope::kFileSystemRead ,
479
- cache_dir_with_tag_str ))) {
474
+ cache_dir_with_tag ))) {
480
475
result.message = " Skipping compile cache because read permission for " +
481
- cache_dir_with_tag_str + " is not granted" ;
476
+ cache_dir_with_tag + " is not granted" ;
482
477
result.status = CompileCacheEnableStatus::FAILED;
483
478
return result;
484
479
}
485
480
486
481
fs::FSReqWrapSync req_wrap;
487
482
int err = fs::MKDirpSync (
488
- nullptr , &(req_wrap.req ), cache_dir_with_tag_str , 0777 , nullptr );
483
+ nullptr , &(req_wrap.req ), cache_dir_with_tag , 0777 , nullptr );
489
484
if (is_debug_) {
490
485
Debug (" [compile cache] creating cache directory %s...%s\n " ,
491
- cache_dir_with_tag_str ,
486
+ cache_dir_with_tag ,
492
487
err < 0 ? uv_strerror (err) : " success" );
493
488
}
494
489
if (err != 0 && err != UV_EEXIST) {
@@ -498,7 +493,6 @@ CompileCacheEnableResult CompileCacheHandler::Enable(Environment* env,
498
493
return result;
499
494
}
500
495
501
- compile_cache_dir_str_ = absolute_cache_dir_base;
502
496
result.cache_directory = absolute_cache_dir_base;
503
497
compile_cache_dir_ = cache_dir_with_tag;
504
498
result.status = CompileCacheEnableStatus::ENABLED;
0 commit comments