66#include " node_internals.h"
77#include " node_version.h"
88#include " path.h"
9+ #include " util.h"
910#include " zlib.h"
1011
1112#ifdef NODE_IMPLEMENTS_POSIX_CREDENTIALS
@@ -225,14 +226,11 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert(
225226 compiler_cache_store_.emplace (key, std::make_unique<CompileCacheEntry>());
226227 auto * result = emplaced.first ->second .get ();
227228
228- std::u8string cache_filename_u8 =
229- (compile_cache_dir_ / Uint32ToHex (key)).u8string ();
230229 result->code_hash = code_hash;
231230 result->code_size = code_utf8.length ();
232231 result->cache_key = key;
233232 result->cache_filename =
234- std::string (cache_filename_u8.begin (), cache_filename_u8.end ()) +
235- " .cache" ;
233+ compile_cache_dir_ + kPathSeparator + Uint32ToHex (key);
236234 result->source_filename = filename_utf8.ToString ();
237235 result->cache = nullptr ;
238236 result->type = type;
@@ -452,43 +450,40 @@ CompileCacheEnableResult CompileCacheHandler::Enable(Environment* env,
452450 const std::string& dir) {
453451 std::string cache_tag = GetCacheVersionTag ();
454452 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;
460455 CompileCacheEnableResult result;
461456 Debug (" [compile cache] resolved path %s + %s -> %s\n " ,
462457 dir,
463458 cache_tag,
464- cache_dir_with_tag_str );
459+ cache_dir_with_tag );
465460
466461 if (UNLIKELY (!env->permission ()->is_granted (
467462 env,
468463 permission::PermissionScope::kFileSystemWrite ,
469- cache_dir_with_tag_str ))) {
464+ cache_dir_with_tag ))) {
470465 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" ;
472467 result.status = CompileCacheEnableStatus::FAILED;
473468 return result;
474469 }
475470
476471 if (UNLIKELY (!env->permission ()->is_granted (
477472 env,
478473 permission::PermissionScope::kFileSystemRead ,
479- cache_dir_with_tag_str ))) {
474+ cache_dir_with_tag ))) {
480475 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" ;
482477 result.status = CompileCacheEnableStatus::FAILED;
483478 return result;
484479 }
485480
486481 fs::FSReqWrapSync req_wrap;
487482 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 );
489484 if (is_debug_) {
490485 Debug (" [compile cache] creating cache directory %s...%s\n " ,
491- cache_dir_with_tag_str ,
486+ cache_dir_with_tag ,
492487 err < 0 ? uv_strerror (err) : " success" );
493488 }
494489 if (err != 0 && err != UV_EEXIST) {
@@ -498,7 +493,6 @@ CompileCacheEnableResult CompileCacheHandler::Enable(Environment* env,
498493 return result;
499494 }
500495
501- compile_cache_dir_str_ = absolute_cache_dir_base;
502496 result.cache_directory = absolute_cache_dir_base;
503497 compile_cache_dir_ = cache_dir_with_tag;
504498 result.status = CompileCacheEnableStatus::ENABLED;
0 commit comments