diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-06-17 11:28:47 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-07-05 12:58:35 +0200 |
commit | c88585ddf9386fb14154a4f3baa702569d55584a (patch) | |
tree | 05461204866831ab88364981390dae474f16247d /src | |
parent | 8c73c618d777a07c017ec0deefe88db83652827e (diff) | |
download | justbuild-c88585ddf9386fb14154a4f3baa702569d55584a.tar.gz |
Use StorageConfig functionality via Instance()
...to track changes during refactoring easier.
Diffstat (limited to 'src')
25 files changed, 403 insertions, 339 deletions
diff --git a/src/buildtool/execution_api/execution_service/bytestream_server.cpp b/src/buildtool/execution_api/execution_service/bytestream_server.cpp index 2a4b7e21..92b06ef6 100644 --- a/src/buildtool/execution_api/execution_service/bytestream_server.cpp +++ b/src/buildtool/execution_api/execution_service/bytestream_server.cpp @@ -131,7 +131,8 @@ auto BytestreamServiceImpl::Write( logger_.Emit(LogLevel::Error, str); return grpc::Status{grpc::StatusCode::INTERNAL, str}; } - auto tmp_dir = StorageConfig::CreateTypedTmpDir("execution-service"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("execution-service"); if (!tmp_dir) { return ::grpc::Status{::grpc::StatusCode::INTERNAL, "could not create TmpDir"}; diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp index 6bce4f13..86192146 100644 --- a/src/buildtool/execution_api/local/local_action.cpp +++ b/src/buildtool/execution_api/local/local_action.cpp @@ -129,7 +129,7 @@ auto LocalAction::Execute(Logger const* logger) noexcept auto LocalAction::Run(bazel_re::Digest const& action_id) const noexcept -> std::optional<Output> { auto exec_path = - CreateUniquePath(StorageConfig::ExecutionRoot() / + CreateUniquePath(StorageConfig::Instance().ExecutionRoot() / NativeSupport::Unprefix(action_id.hash())); if (not exec_path) { diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index 39c0970b..93c763ae 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -1714,7 +1714,8 @@ auto GitRepo::LocalFetchViaTmpRepo(std::string const& repo_path, Logger::Log(LogLevel::Debug, "Branch local fetch called on a real repository"); } - auto tmp_dir = StorageConfig::CreateTypedTmpDir("local_fetch"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("local_fetch"); if (not tmp_dir) { (*logger)("Failed to create temp dir for Git repository", /*fatal=*/true); diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 0e72890a..2b3add04 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -110,7 +110,7 @@ void SetupExecutionConfig(EndpointArguments const& eargs, using LocalConfig = LocalExecutionConfig; using RemoteConfig = RemoteExecutionConfig; if (not(not eargs.local_root or - (StorageConfig::SetBuildRoot(*eargs.local_root))) or + (StorageConfig::Instance().SetBuildRoot(*eargs.local_root))) or not(not bargs.local_launcher or LocalConfig::SetLauncher(*bargs.local_launcher))) { Logger::Log(LogLevel::Error, "Failed to configure local execution."); @@ -881,10 +881,11 @@ auto main(int argc, char* argv[]) -> int { ProgressReporter::Reporter(&stats, &progress)}; if (arguments.cmd == SubCommand::kInstallCas) { - if (not repo_config.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo_config.SetGitCAS( + StorageConfig::Instance().GitRoot())) { Logger::Log(LogLevel::Debug, "Failed set Git CAS {}.", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); } return FetchAndInstallArtifacts(main_apis, arguments.fetch) ? kExitSuccess diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp index 906f331c..9016fd82 100644 --- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp +++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp @@ -93,16 +93,17 @@ auto ServeServerImpl::Run(RemoteServeConfig const& serve_config, ApiBundle const& apis, bool with_execute) -> bool { // make sure the git root directory is properly initialized - if (not FileSystemManager::CreateDirectory(StorageConfig::GitRoot())) { + if (not FileSystemManager::CreateDirectory( + StorageConfig::Instance().GitRoot())) { Logger::Log(LogLevel::Error, "Could not create directory {}. Aborting", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); return false; } - if (not GitRepo::InitAndOpen(StorageConfig::GitRoot(), true)) { + if (not GitRepo::InitAndOpen(StorageConfig::Instance().GitRoot(), true)) { Logger::Log(LogLevel::Error, fmt::format("could not initialize bare git repository {}", - StorageConfig::GitRoot().string())); + StorageConfig::Instance().GitRoot().string())); return false; } diff --git a/src/buildtool/serve_api/serve_service/source_tree.cpp b/src/buildtool/serve_api/serve_service/source_tree.cpp index 8e105eee..b7e5d59c 100644 --- a/src/buildtool/serve_api/serve_service/source_tree.cpp +++ b/src/buildtool/serve_api/serve_service/source_tree.cpp @@ -202,8 +202,8 @@ auto SourceTreeService::ServeCommitTree( auto const& commit{request->commit()}; auto const& subdir{request->subdir()}; // try in local build root Git cache - auto res = - GetSubtreeFromCommit(StorageConfig::GitRoot(), commit, subdir, logger_); + auto res = GetSubtreeFromCommit( + StorageConfig::Instance().GitRoot(), commit, subdir, logger_); if (res) { auto tree_id = *std::move(res); if (request->sync_tree()) { @@ -219,10 +219,10 @@ auto SourceTreeService::ServeCommitTree( } auto digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}; auto repo = RepositoryConfig{}; - if (not repo.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { logger_->Emit(LogLevel::Error, "Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeCommitTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -251,7 +251,7 @@ auto SourceTreeService::ServeCommitTree( "repository {}", subdir, commit, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeCommitTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -390,11 +390,11 @@ auto SourceTreeService::ResolveContentTree( *resolved_tree_id, repo_path, sync_tree, response); } // resolve tree; target repository is always the Git cache - auto target_cas = GitCAS::Open(StorageConfig::GitRoot()); + auto target_cas = GitCAS::Open(StorageConfig::Instance().GitRoot()); if (not target_cas) { logger_->Emit(LogLevel::Error, "Failed to open Git ODB at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -456,7 +456,7 @@ auto SourceTreeService::ResolveContentTree( logger->Emit(LogLevel::Error, "While keeping tree {} in repository {}:\n{}", resolved_tree.id, - StorageConfig::GitRoot().string(), + StorageConfig::Instance().GitRoot().string(), msg); } }); @@ -464,11 +464,11 @@ auto SourceTreeService::ResolveContentTree( // this is a non-thread-safe Git operation, so it must be guarded! std::shared_lock slock{mutex_}; // open real repository at Git CAS location - auto git_repo = GitRepo::Open(StorageConfig::GitRoot()); + auto git_repo = GitRepo::Open(StorageConfig::Instance().GitRoot()); if (not git_repo) { logger_->Emit(LogLevel::Error, "Failed to open Git CAS repository {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::RESOLVE_ERROR); return ::grpc::Status::OK; } @@ -522,15 +522,17 @@ auto SourceTreeService::CommonImportToGit( return unexpected{err}; } // open the Git CAS repo - auto just_git_cas = GitCAS::Open(StorageConfig::GitRoot()); + auto just_git_cas = GitCAS::Open(StorageConfig::Instance().GitRoot()); if (not just_git_cas) { - return unexpected{fmt::format("Failed to open Git ODB at {}", - StorageConfig::GitRoot().string())}; + return unexpected{ + fmt::format("Failed to open Git ODB at {}", + StorageConfig::Instance().GitRoot().string())}; } auto just_git_repo = GitRepo::Open(just_git_cas); if (not just_git_repo) { - return unexpected{fmt::format("Failed to open Git repository {}", - StorageConfig::GitRoot().string())}; + return unexpected{ + fmt::format("Failed to open Git repository {}", + StorageConfig::Instance().GitRoot().string())}; } // wrap logger for GitRepo call err.clear(); @@ -538,7 +540,7 @@ auto SourceTreeService::CommonImportToGit( [&err](auto const& msg, bool fatal) { if (fatal) { err = fmt::format("While fetching in repository {}:\n{}", - StorageConfig::GitRoot().string(), + StorageConfig::Instance().GitRoot().string(), msg); } }); @@ -557,7 +559,7 @@ auto SourceTreeService::CommonImportToGit( err = fmt::format("While tagging commit {} in repository {}:\n{}", *commit_hash, - StorageConfig::GitRoot().string(), + StorageConfig::Instance().GitRoot().string(), msg); } }); @@ -566,11 +568,11 @@ auto SourceTreeService::CommonImportToGit( // this is a non-thread-safe Git operation, so it must be guarded! std::shared_lock slock{mutex_}; // open real repository at Git CAS location - auto git_repo = GitRepo::Open(StorageConfig::GitRoot()); + auto git_repo = GitRepo::Open(StorageConfig::Instance().GitRoot()); if (not git_repo) { return unexpected{ fmt::format("Failed to open Git CAS repository {}", - StorageConfig::GitRoot().string())}; + StorageConfig::Instance().GitRoot().string())}; } // Important: message must be consistent with just-mr! if (not git_repo->KeepTag(*commit_hash, @@ -628,11 +630,11 @@ auto SourceTreeService::ArchiveImportToGit( return ::grpc::Status::OK; } // open the Git CAS repo - auto just_git_cas = GitCAS::Open(StorageConfig::GitRoot()); + auto just_git_cas = GitCAS::Open(StorageConfig::Instance().GitRoot()); if (not just_git_cas) { logger_->Emit(LogLevel::Error, "Failed to open Git ODB at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -640,7 +642,7 @@ auto SourceTreeService::ArchiveImportToGit( if (not just_git_repo) { logger_->Emit(LogLevel::Error, "Failed to open Git repository {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -664,7 +666,7 @@ auto SourceTreeService::ArchiveImportToGit( return ::grpc::Status::OK; } return ResolveContentTree(*subtree_id, - StorageConfig::GitRoot(), + StorageConfig::Instance().GitRoot(), /*repo_is_git_cache=*/true, resolve_special, sync_tree, @@ -723,11 +725,13 @@ auto SourceTreeService::ServeArchiveTree( return ::grpc::Status::OK; } // check local build root Git cache - auto res = GetSubtreeFromTree( - StorageConfig::GitRoot(), *archive_tree_id, subdir, logger_); + auto res = GetSubtreeFromTree(StorageConfig::Instance().GitRoot(), + *archive_tree_id, + subdir, + logger_); if (res) { return ResolveContentTree(*res, // tree_id - StorageConfig::GitRoot(), + StorageConfig::Instance().GitRoot(), /*repo_is_git_cache=*/true, resolve_special, request->sync_tree(), @@ -737,7 +741,7 @@ auto SourceTreeService::ServeArchiveTree( if (res.error() == GitLookupError::Fatal) { logger_->Emit(LogLevel::Error, "Failed to open repository {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -784,7 +788,8 @@ auto SourceTreeService::ServeArchiveTree( if (content_cas_path = cas.BlobPath(digest, /*is_executable=*/false); not content_cas_path) { // check if content blob is in Git cache - auto res = GetBlobFromRepo(StorageConfig::GitRoot(), content, logger_); + auto res = GetBlobFromRepo( + StorageConfig::Instance().GitRoot(), content, logger_); if (res) { // add to CAS content_cas_path = StorageUtils::AddToCAS(*res); @@ -794,7 +799,7 @@ auto SourceTreeService::ServeArchiveTree( LogLevel::Error, "Failed while trying to retrieve content {} from repository {}", content, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeArchiveTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -843,7 +848,7 @@ auto SourceTreeService::ServeArchiveTree( } } // extract archive - auto tmp_dir = StorageConfig::CreateTypedTmpDir(archive_type); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir(archive_type); if (not tmp_dir) { logger_->Emit( LogLevel::Error, @@ -882,7 +887,8 @@ auto SourceTreeService::DistdirImportToGit( bool sync_tree, ServeDistdirTreeResponse* response) -> ::grpc::Status { // create tmp directory for the distdir - auto distdir_tmp_dir = StorageConfig::CreateTypedTmpDir("distdir"); + auto distdir_tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("distdir"); if (not distdir_tmp_dir) { logger_->Emit(LogLevel::Error, "Failed to create tmp path for distdir target {}", @@ -948,10 +954,10 @@ auto SourceTreeService::DistdirImportToGit( } auto digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}; auto repo = RepositoryConfig{}; - if (not repo.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { logger_->Emit(LogLevel::Error, "Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeDistdirTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1015,8 +1021,8 @@ auto SourceTreeService::ServeDistdirTree( } else { // check local Git cache - auto res = - GetBlobFromRepo(StorageConfig::GitRoot(), content, logger_); + auto res = GetBlobFromRepo( + StorageConfig::Instance().GitRoot(), content, logger_); if (res) { // add content to local CAS auto stored_blob = cas.StoreBlob(*res, kv.executable()); @@ -1038,7 +1044,7 @@ auto SourceTreeService::ServeDistdirTree( "Failed while trying to retrieve content {} " "from repository {}", content, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status( ServeDistdirTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; @@ -1156,12 +1162,13 @@ auto SourceTreeService::ServeDistdirTree( return ::grpc::Status::OK; } // check if tree is already in Git cache - auto has_tree = IsTreeInRepo(tree_id, StorageConfig::GitRoot(), logger_); + auto has_tree = + IsTreeInRepo(tree_id, StorageConfig::Instance().GitRoot(), logger_); if (not has_tree) { logger_->Emit(LogLevel::Error, "Failed while checking for tree {} in repository {}", tree_id, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeDistdirTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1180,10 +1187,10 @@ auto SourceTreeService::ServeDistdirTree( } auto digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}; auto repo = RepositoryConfig{}; - if (not repo.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { logger_->Emit(LogLevel::Error, "Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeDistdirTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1277,14 +1284,15 @@ auto SourceTreeService::ServeContent( } auto const digest = ArtifactDigest{content, 0, /*is_tree=*/false}; // check if content blob is in Git cache - auto res = GetBlobFromRepo(StorageConfig::GitRoot(), content, logger_); + auto res = + GetBlobFromRepo(StorageConfig::Instance().GitRoot(), content, logger_); if (res) { // upload blob to remote CAS auto repo = RepositoryConfig{}; - if (not repo.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { logger_->Emit(LogLevel::Error, "Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeContentResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1307,7 +1315,7 @@ auto SourceTreeService::ServeContent( logger_->Emit(LogLevel::Error, "Failed while checking for content {} in repository {}", content, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeContentResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1386,12 +1394,13 @@ auto SourceTreeService::ServeTree( } auto digest = ArtifactDigest{tree_id, 0, /*is_tree=*/true}; // check if tree is in Git cache - auto has_tree = IsTreeInRepo(tree_id, StorageConfig::GitRoot(), logger_); + auto has_tree = + IsTreeInRepo(tree_id, StorageConfig::Instance().GitRoot(), logger_); if (not has_tree) { logger_->Emit(LogLevel::Error, "Failed while checking for tree {} in repository {}", tree_id, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1406,10 +1415,10 @@ auto SourceTreeService::ServeTree( return ::grpc::Status::OK; } auto repo = RepositoryConfig{}; - if (not repo.SetGitCAS(StorageConfig::GitRoot())) { + if (not repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { logger_->Emit(LogLevel::Error, "Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(ServeTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1518,12 +1527,13 @@ auto SourceTreeService::CheckRootTree( return ::grpc::Status::OK; } // check first in the Git cache - auto has_tree = IsTreeInRepo(tree_id, StorageConfig::GitRoot(), logger_); + auto has_tree = + IsTreeInRepo(tree_id, StorageConfig::Instance().GitRoot(), logger_); if (not has_tree) { logger_->Emit(LogLevel::Error, "Failed while checking for tree {} in repository {}", tree_id, - StorageConfig::GitRoot().string()); + StorageConfig::Instance().GitRoot().string()); response->set_status(CheckRootTreeResponse::INTERNAL_ERROR); return ::grpc::Status::OK; } @@ -1554,8 +1564,8 @@ auto SourceTreeService::CheckRootTree( if (auto path = Storage::Instance().CAS().TreePath(digest)) { // As we currently build only against roots in Git repositories, we need // to move the tree from CAS to local Git storage - auto tmp_dir = - StorageConfig::CreateTypedTmpDir("source-tree-check-root-tree"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir( + "source-tree-check-root-tree"); if (not tmp_dir) { logger_->Emit(LogLevel::Error, "Failed to create tmp directory for copying git-tree " @@ -1627,8 +1637,8 @@ auto SourceTreeService::GetRemoteTree( response->set_status(GetRemoteTreeResponse::FAILED_PRECONDITION); return ::grpc::Status::OK; } - auto tmp_dir = - StorageConfig::CreateTypedTmpDir("source-tree-get-remote-tree"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir( + "source-tree-get-remote-tree"); if (not tmp_dir) { logger_->Emit(LogLevel::Error, "Failed to create tmp directory for copying git-tree {} " diff --git a/src/buildtool/serve_api/serve_service/target.cpp b/src/buildtool/serve_api/serve_service/target.cpp index 44632590..afafb720 100644 --- a/src/buildtool/serve_api/serve_service/target.cpp +++ b/src/buildtool/serve_api/serve_service/target.cpp @@ -435,7 +435,7 @@ auto TargetService::ServeTarget( Progress progress{}; // setup logging for analysis and build; write into a temporary file - auto tmp_dir = StorageConfig::CreateTypedTmpDir("serve-target"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("serve-target"); if (!tmp_dir) { auto msg = std::string("Could not create TmpDir"); logger_->Emit(LogLevel::Error, msg); @@ -592,8 +592,10 @@ auto TargetService::ServeTargetVariables( std::optional<std::string> target_file_content{std::nullopt}; bool tree_found{false}; // try in local build root Git cache - if (auto res = GetBlobContent( - StorageConfig::GitRoot(), root_tree, target_file, logger_)) { + if (auto res = GetBlobContent(StorageConfig::Instance().GitRoot(), + root_tree, + target_file, + logger_)) { tree_found = true; if (res->first) { if (not res->second) { @@ -746,8 +748,10 @@ auto TargetService::ServeTargetDescription( std::optional<std::string> target_file_content{std::nullopt}; bool tree_found{false}; // try in local build root Git cache - if (auto res = GetBlobContent( - StorageConfig::GitRoot(), root_tree, target_file, logger_)) { + if (auto res = GetBlobContent(StorageConfig::Instance().GitRoot(), + root_tree, + target_file, + logger_)) { tree_found = true; if (res->first) { if (not res->second) { diff --git a/src/buildtool/serve_api/serve_service/target_utils.cpp b/src/buildtool/serve_api/serve_service/target_utils.cpp index 5e8411ca..c2dd0422 100644 --- a/src/buildtool/serve_api/serve_service/target_utils.cpp +++ b/src/buildtool/serve_api/serve_service/target_utils.cpp @@ -58,8 +58,8 @@ auto GetServingRepository(RemoteServeConfig const& serve_config, std::shared_ptr<Logger> const& logger) -> std::optional<std::filesystem::path> { // try the Git cache repository - if (IsTreeInRepo(tree_id, StorageConfig::GitRoot(), logger)) { - return StorageConfig::GitRoot(); + if (IsTreeInRepo(tree_id, StorageConfig::Instance().GitRoot(), logger)) { + return StorageConfig::Instance().GitRoot(); } // check the known repositories for (auto const& path : serve_config.known_repositories) { diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp index 44ba6968..38cdc45a 100644 --- a/src/buildtool/storage/config.hpp +++ b/src/buildtool/storage/config.hpp @@ -38,57 +38,57 @@ class StorageConfig { return config; } - [[nodiscard]] static auto SetBuildRoot( - std::filesystem::path const& dir) noexcept -> bool { + [[nodiscard]] auto SetBuildRoot(std::filesystem::path const& dir) noexcept + -> bool { if (FileSystemManager::IsRelativePath(dir)) { Logger::Log(LogLevel::Error, "Build root must be absolute path but got '{}'.", dir.string()); return false; } - Instance().build_root_ = dir; + build_root_ = dir; return true; } /// \brief Specifies the number of storage generations. - static auto SetNumGenerations(std::size_t num_generations) noexcept - -> void { - Instance().num_generations_ = num_generations; + auto SetNumGenerations(std::size_t num_generations) noexcept -> void { + num_generations_ = num_generations; } /// \brief Number of storage generations. - [[nodiscard]] static auto NumGenerations() noexcept -> std::size_t { - return Instance().num_generations_; + [[nodiscard]] auto NumGenerations() const noexcept -> std::size_t { + return num_generations_; } /// \brief Build directory, defaults to user directory if not set - [[nodiscard]] static auto BuildRoot() noexcept -> std::filesystem::path { - return Instance().build_root_; + [[nodiscard]] auto BuildRoot() const noexcept + -> std::filesystem::path const& { + return build_root_; } /// \brief Root directory of all storage generations. - [[nodiscard]] static auto CacheRoot() noexcept -> std::filesystem::path { + [[nodiscard]] auto CacheRoot() const noexcept -> std::filesystem::path { return BuildRoot() / "protocol-dependent"; } /// \brief Directory for the git repository storing various roots - [[nodiscard]] static auto GitRoot() noexcept -> std::filesystem::path { + [[nodiscard]] auto GitRoot() const noexcept -> std::filesystem::path { return BuildRoot() / "git"; } /// \brief Root directory of specific storage generation for compatible and /// non-compatible protocol types. - [[nodiscard]] static auto GenerationCacheRoot(std::size_t index) noexcept + [[nodiscard]] auto GenerationCacheRoot(std::size_t index) const noexcept -> std::filesystem::path { - ExpectsAudit(index < Instance().num_generations_); + ExpectsAudit(index < num_generations_); auto generation = std::string{"generation-"} + std::to_string(index); return CacheRoot() / generation; } /// \brief Storage directory of specific generation and protocol type. - [[nodiscard]] static auto GenerationCacheDir( + [[nodiscard]] auto GenerationCacheDir( std::size_t index, - bool is_compatible = Compatibility::IsCompatible()) noexcept + bool is_compatible = Compatibility::IsCompatible()) const noexcept -> std::filesystem::path { return UpdatePathForCompatibility(GenerationCacheRoot(index), is_compatible); @@ -96,22 +96,20 @@ class StorageConfig { /// \brief Root directory for all ephemeral directories, i.e., directories /// that can (and should) be removed immediately by garbage collection. - [[nodiscard]] static auto EphemeralRoot() noexcept - -> std::filesystem::path { + [[nodiscard]] auto EphemeralRoot() const noexcept -> std::filesystem::path { return GenerationCacheRoot(0) / "ephemeral"; } /// \brief Root directory for local action executions; individual actions /// create a working directory below this root. - [[nodiscard]] static auto ExecutionRoot() noexcept - -> std::filesystem::path { + [[nodiscard]] auto ExecutionRoot() const noexcept -> std::filesystem::path { return EphemeralRoot() / "exec_root"; } /// \brief Create a tmp directory with controlled lifetime for specific /// operations (archive, zip, file, distdir checkouts; fetch; update). - [[nodiscard]] static auto CreateTypedTmpDir( - std::string const& type) noexcept -> TmpDirPtr { + [[nodiscard]] auto CreateTypedTmpDir(std::string const& type) const noexcept + -> TmpDirPtr { // try to create parent dir auto parent_path = EphemeralRoot() / "tmp-workspaces" / type; return TmpDir::Create(parent_path); diff --git a/src/buildtool/storage/fs_utils.cpp b/src/buildtool/storage/fs_utils.cpp index 95b5e72b..539e0956 100644 --- a/src/buildtool/storage/fs_utils.cpp +++ b/src/buildtool/storage/fs_utils.cpp @@ -48,18 +48,19 @@ auto GetGitRoot(LocalPathsPtr const& just_mr_paths, FileSystemManager::IsDirectory(repo_url_as_path)) { return repo_url_as_path; } - return StorageConfig::GitRoot(); + return StorageConfig::Instance().GitRoot(); } auto GetCommitTreeIDFile(std::string const& commit) noexcept -> std::filesystem::path { - return StorageConfig::BuildRoot() / "commit-tree-map" / commit; + return StorageConfig::Instance().BuildRoot() / "commit-tree-map" / commit; } auto GetArchiveTreeIDFile(std::string const& repo_type, std::string const& content) noexcept -> std::filesystem::path { - return StorageConfig::BuildRoot() / "tree-map" / repo_type / content; + return StorageConfig::Instance().BuildRoot() / "tree-map" / repo_type / + content; } auto GetForeignFileTreeIDFile(std::string const& content, @@ -77,13 +78,14 @@ auto GetForeignFileTreeIDFile(std::string const& content, auto GetDistdirTreeIDFile(std::string const& content) noexcept -> std::filesystem::path { - return StorageConfig::BuildRoot() / "distfiles-tree-map" / content; + return StorageConfig::Instance().BuildRoot() / "distfiles-tree-map" / + content; } auto GetResolvedTreeIDFile(std::string const& tree_hash, PragmaSpecial const& pragma_special) noexcept -> std::filesystem::path { - return StorageConfig::BuildRoot() / "special-tree-map" / + return StorageConfig::Instance().BuildRoot() / "special-tree-map" / kPragmaSpecialInverseMap.at(pragma_special) / tree_hash; } diff --git a/src/buildtool/storage/garbage_collector.cpp b/src/buildtool/storage/garbage_collector.cpp index d317974e..3fe876c7 100644 --- a/src/buildtool/storage/garbage_collector.cpp +++ b/src/buildtool/storage/garbage_collector.cpp @@ -64,7 +64,8 @@ auto GarbageCollector::GlobalUplinkBlob(bazel_re::Digest const& digest, bool is_executable) noexcept -> bool { // Try to find blob in all generations. auto const& latest_cas = Storage::Generation(0).CAS(); - for (std::size_t i = 0; i < StorageConfig::NumGenerations(); ++i) { + for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations(); + ++i) { // Note that we uplink with _skip_sync_ as we want to prefer hard links // from older generations over copies from the companion file/exec CAS. if (Storage::Generation(i).CAS().LocalUplinkBlob( @@ -83,7 +84,8 @@ auto GarbageCollector::GlobalUplinkLargeBlob( bazel_re::Digest const& digest) noexcept -> bool { // Try to find large entry in all generations. auto const& latest_cas = Storage::Generation(0).CAS(); - for (std::size_t i = 0; i < StorageConfig::NumGenerations(); ++i) { + for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations(); + ++i) { if (Storage::Generation(i) .CAS() .LocalUplinkLargeObject<ObjectType::File>(latest_cas, digest)) { @@ -97,7 +99,8 @@ auto GarbageCollector::GlobalUplinkTree(bazel_re::Digest const& digest) noexcept -> bool { // Try to find tree in all generations. auto const& latest_cas = Storage::Generation(0).CAS(); - for (std::size_t i = 0; i < StorageConfig::NumGenerations(); ++i) { + for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations(); + ++i) { if (Storage::Generation(i).CAS().LocalUplinkTree( latest_cas, digest, /*splice_result=*/true)) { return true; @@ -110,7 +113,8 @@ auto GarbageCollector::GlobalUplinkActionCacheEntry( bazel_re::Digest const& action_id) noexcept -> bool { // Try to find action-cache entry in all generations. auto const& latest_ac = Storage::Generation(0).ActionCache(); - for (std::size_t i = 0; i < StorageConfig::NumGenerations(); ++i) { + for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations(); + ++i) { if (Storage::Generation(i).ActionCache().LocalUplinkEntry(latest_ac, action_id)) { return true; @@ -125,7 +129,8 @@ auto GarbageCollector::GlobalUplinkTargetCacheEntry( // Try to find target-cache entry in all generations. auto const& latest_tc = Storage::Generation(0).TargetCache().WithShard(shard); - for (std::size_t i = 0; i < StorageConfig::NumGenerations(); ++i) { + for (std::size_t i = 0; i < StorageConfig::Instance().NumGenerations(); + ++i) { if (Storage::Generation(i) .TargetCache() .WithShard(shard) @@ -145,7 +150,7 @@ auto GarbageCollector::ExclusiveLock() noexcept -> std::optional<LockFile> { } auto GarbageCollector::LockFilePath() noexcept -> std::filesystem::path { - return StorageConfig::CacheRoot() / "gc.lock"; + return StorageConfig::Instance().CacheRoot() / "gc.lock"; } auto GarbageCollector::TriggerGarbageCollection(bool no_rotation) noexcept @@ -169,8 +174,8 @@ auto GarbageCollector::TriggerGarbageCollection(bool no_rotation) noexcept return false; } - for (auto const& entry : - std::filesystem::directory_iterator(StorageConfig::CacheRoot())) { + for (auto const& entry : std::filesystem::directory_iterator( + StorageConfig::Instance().CacheRoot())) { if (entry.path().filename().string().find(remove_me_prefix) == 0) { to_remove.emplace_back(entry.path()); } @@ -200,15 +205,15 @@ auto GarbageCollector::TriggerGarbageCollection(bool no_rotation) noexcept // all existing remove-me directories; they're left overs, as the clean // up of owned directories is done with a shared lock. std::vector<std::filesystem::path> left_over{}; - for (auto const& entry : - std::filesystem::directory_iterator(StorageConfig::CacheRoot())) { + for (auto const& entry : std::filesystem::directory_iterator( + StorageConfig::Instance().CacheRoot())) { if (entry.path().filename().string().find(kRemoveMe) == 0) { left_over.emplace_back(entry.path()); } } for (auto const& d : left_over) { auto new_name = - StorageConfig::CacheRoot() / + StorageConfig::Instance().CacheRoot() / fmt::format("{}{}", remove_me_prefix, remove_me_counter++); if (FileSystemManager::Rename(d, new_name)) { to_remove.emplace_back(new_name); @@ -224,10 +229,10 @@ auto GarbageCollector::TriggerGarbageCollection(bool no_rotation) noexcept // Now that the have to exclusive lock, try to move out ephemeral data; // as it is still under the generation regime, it is not a huge problem // if that fails. - auto ephemeral = StorageConfig::EphemeralRoot(); + auto ephemeral = StorageConfig::Instance().EphemeralRoot(); if (FileSystemManager::IsDirectory(ephemeral)) { auto remove_me_dir = - StorageConfig::CacheRoot() / + StorageConfig::Instance().CacheRoot() / fmt::format("{}{}", remove_me_prefix, remove_me_counter++); if (FileSystemManager::Rename(ephemeral, remove_me_dir)) { to_remove.emplace_back(remove_me_dir); @@ -252,16 +257,19 @@ auto GarbageCollector::TriggerGarbageCollection(bool no_rotation) noexcept // Rotate generations unless told not to do so if (not no_rotation) { auto remove_me_dir = - StorageConfig::CacheRoot() / + StorageConfig::Instance().CacheRoot() / fmt::format("{}{}", remove_me_prefix, remove_me_counter++); to_remove.emplace_back(remove_me_dir); - for (std::size_t i = StorageConfig::NumGenerations(); i > 0; --i) { - auto cache_root = StorageConfig::GenerationCacheRoot(i - 1); + for (std::size_t i = StorageConfig::Instance().NumGenerations(); + i > 0; + --i) { + auto cache_root = + StorageConfig::Instance().GenerationCacheRoot(i - 1); if (FileSystemManager::IsDirectory(cache_root)) { auto new_cache_root = - (i == StorageConfig::NumGenerations()) + (i == StorageConfig::Instance().NumGenerations()) ? remove_me_dir - : StorageConfig::GenerationCacheRoot(i); + : StorageConfig::Instance().GenerationCacheRoot(i); if (not FileSystemManager::Rename(cache_root, new_cache_root)) { Logger::Log(LogLevel::Error, @@ -302,8 +310,8 @@ auto GarbageCollector::Compactify(size_t threshold) noexcept -> bool { // Compactification must be done for both native and compatible storages. auto compactify = [threshold](bool compatible) -> bool { Compatibility::SetCompatible(compatible); - auto const storage = - ::Generation(StorageConfig::GenerationCacheDir(0, compatible)); + auto const storage = ::Generation( + StorageConfig::Instance().GenerationCacheDir(0, compatible)); return Compactifier::RemoveInvalid(storage.CAS()) and Compactifier::RemoveSpliced(storage.CAS()) and diff --git a/src/buildtool/storage/large_object_cas.hpp b/src/buildtool/storage/large_object_cas.hpp index 6f287379..86c00171 100644 --- a/src/buildtool/storage/large_object_cas.hpp +++ b/src/buildtool/storage/large_object_cas.hpp @@ -70,7 +70,7 @@ class LargeObjectError final { class LargeObject final { public: LargeObject() noexcept - : directory_(StorageConfig::CreateTypedTmpDir("splice")), + : directory_(StorageConfig::Instance().CreateTypedTmpDir("splice")), path_(directory_ ? directory_->GetPath() / "result" : ".") {} /// \brief Check whether the large object is valid. diff --git a/src/buildtool/storage/storage.hpp b/src/buildtool/storage/storage.hpp index 95d06495..960699f1 100644 --- a/src/buildtool/storage/storage.hpp +++ b/src/buildtool/storage/storage.hpp @@ -82,14 +82,16 @@ using Generation = LocalStorage</*kDoGlobalUplink=*/false>; class Storage : public LocalStorage<kDefaultDoGlobalUplink> { public: /// \brief Get the global storage instance. - /// Build root is read from \ref StorageConfig::BuildRoot(). + /// Build root is read from \ref + /// StorageConfig::Instance().BuildRoot(). /// \returns The global storage singleton instance. [[nodiscard]] static auto Instance() noexcept -> Storage const& { return GetStorage(); } /// \brief Get specific storage generation. - /// Number of generations is read from \ref StorageConfig::NumGenerations(). + /// Number of generations is read from \ref + /// StorageConfig::Instance().NumGenerations(). /// \param index the generation index (0 is latest). /// \returns The specific storage generation. [[nodiscard]] static auto Generation(std::size_t index) noexcept @@ -108,16 +110,17 @@ class Storage : public LocalStorage<kDefaultDoGlobalUplink> { using LocalStorage<kDefaultDoGlobalUplink>::LocalStorage; [[nodiscard]] static auto CreateStorage() noexcept -> Storage { - return Storage{StorageConfig::GenerationCacheDir(0)}; + return Storage{StorageConfig::Instance().GenerationCacheDir(0)}; } [[nodiscard]] static auto CreateGenerations() noexcept -> std::vector<::Generation> { - auto count = StorageConfig::NumGenerations(); + auto count = StorageConfig::Instance().NumGenerations(); std::vector<::Generation> generations{}; generations.reserve(count); for (std::size_t i = 0; i < count; ++i) { - generations.emplace_back(StorageConfig::GenerationCacheDir(i)); + generations.emplace_back( + StorageConfig::Instance().GenerationCacheDir(i)); } return generations; } diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index 421de1e2..80a2f956 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -405,7 +405,7 @@ auto GitRepoRemote::UpdateCommitViaTmpRepo( anon_logger_ptr const& logger) const noexcept -> std::optional<std::string> { try { - auto tmp_dir = StorageConfig::CreateTypedTmpDir("update"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("update"); if (not tmp_dir) { (*logger)("Failed to create temp dir for running 'git ls-remote'", /*fatal=*/true); @@ -540,7 +540,7 @@ auto GitRepoRemote::FetchViaTmpRepo(std::string const& repo_url, anon_logger_ptr const& logger) noexcept -> bool { try { - auto tmp_dir = StorageConfig::CreateTypedTmpDir("fetch"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("fetch"); if (not tmp_dir) { (*logger)("Failed to create temp dir for running 'git fetch'", /*fatal=*/true); diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 23a81f59..1d1e5a43 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -288,7 +288,7 @@ auto main(int argc, char* argv[]) -> int { // Setup LocalStorageConfig to store the local_build_root properly // and make the cas and git cache roots available - if (not StorageConfig::SetBuildRoot( + if (not StorageConfig::Instance().SetBuildRoot( *arguments.common.just_mr_paths->root)) { Logger::Log(LogLevel::Error, "Failed to configure local build root."); diff --git a/src/other_tools/just_mr/update.cpp b/src/other_tools/just_mr/update.cpp index 38fac998..7c6e9506 100644 --- a/src/other_tools/just_mr/update.cpp +++ b/src/other_tools/just_mr/update.cpp @@ -191,7 +191,7 @@ auto MultiRepoUpdate(std::shared_ptr<Configuration> const& config, } } // Create fake repo for the anonymous remotes - auto tmp_dir = StorageConfig::CreateTypedTmpDir("update"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("update"); if (not tmp_dir) { Logger::Log(LogLevel::Error, "Failed to create commit update tmp dir"); return kExitUpdateError; diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp index 013f49c6..8877a547 100644 --- a/src/other_tools/ops_maps/content_cas_map.cpp +++ b/src/other_tools/ops_maps/content_cas_map.cpp @@ -130,15 +130,16 @@ auto CreateContentCASMap( } // check if content is in Git cache; // ensure Git cache - GitOpKey op_key = {.params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = { + .params = + { + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -240,8 +241,8 @@ auto CreateContentCASMap( FetchFromNetwork( key, additional_mirrors, ca_info, setter, logger); }, - [logger, target_path = StorageConfig::GitRoot()](auto const& msg, - bool fatal) { + [logger, target_path = StorageConfig::Instance().GitRoot()]( + auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git op " "ENSURE_INIT for target {}:\n{}", target_path.string(), diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp index d56c79c7..0e84689a 100644 --- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp +++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp @@ -39,7 +39,7 @@ void BackupToRemote(std::string const& tree_id, GitTreeFetchMap::LoggerPtr const& logger) { // try to back up to remote CAS auto repo = RepositoryConfig{}; - if (repo.SetGitCAS(StorageConfig::GitRoot())) { + if (repo.SetGitCAS(StorageConfig::Instance().GitRoot())) { auto git_api = GitApi{&repo}; if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{ @@ -56,7 +56,7 @@ void BackupToRemote(std::string const& tree_id, else { // give a warning (*logger)(fmt::format("Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()), + StorageConfig::Instance().GitRoot().string()), /*fatal=*/false); } } @@ -73,7 +73,8 @@ void MoveCASTreeToGit(std::string const& tree_id, GitTreeFetchMap::SetterPtr const& setter, GitTreeFetchMap::LoggerPtr const& logger) { // Move tree from CAS to local Git storage - auto tmp_dir = StorageConfig::CreateTypedTmpDir("fetch-remote-git-tree"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("fetch-remote-git-tree"); if (not tmp_dir) { (*logger)(fmt::format("Failed to create tmp directory for copying " "git-tree {} from remote CAS", @@ -147,15 +148,16 @@ auto CreateGitTreeFetchMap( auto const& key) { // check whether tree exists already in Git cache; // ensure Git cache exists - GitOpKey op_key = {.params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = { + .params = + { + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -182,8 +184,9 @@ auto CreateGitTreeFetchMap( auto git_repo = GitRepoRemote::Open( op_result.git_cas); // link fake repo to odb if (not git_repo) { - (*logger)(fmt::format("Could not open repository {}", - StorageConfig::GitRoot().string()), + (*logger)(fmt::format( + "Could not open repository {}", + StorageConfig::Instance().GitRoot().string()), /*fatal=*/true); return; } @@ -258,7 +261,8 @@ auto CreateGitTreeFetchMap( return; } // create temporary location for command execution root - auto tmp_dir = StorageConfig::CreateTypedTmpDir("git-tree"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("git-tree"); if (not tmp_dir) { (*logger)( "Failed to create execution root tmp directory for " @@ -267,7 +271,8 @@ auto CreateGitTreeFetchMap( return; } // create temporary location for storing command result files - auto out_dir = StorageConfig::CreateTypedTmpDir("git-tree"); + auto out_dir = + StorageConfig::Instance().CreateTypedTmpDir("git-tree"); if (not out_dir) { (*logger)( "Failed to create results tmp directory for tree id " @@ -396,7 +401,8 @@ auto CreateGitTreeFetchMap( } // define temp repo path auto tmp_dir = - StorageConfig::CreateTypedTmpDir("git-tree"); + StorageConfig::Instance().CreateTypedTmpDir( + "git-tree"); ; if (not tmp_dir) { (*logger)(fmt::format("Could not create unique " @@ -442,7 +448,8 @@ auto CreateGitTreeFetchMap( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path + StorageConfig::Instance() + .GitRoot(), // target_path *op_result.result, // git_hash "", // branch "Keep referenced tree alive" // message @@ -488,8 +495,8 @@ auto CreateGitTreeFetchMap( fatal); }); }, - [logger, target_path = StorageConfig::GitRoot()](auto const& msg, - bool fatal) { + [logger, target_path = StorageConfig::Instance().GitRoot()]( + auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git op " "ENSURE_INIT bare for target {}:\n{}", target_path.string(), diff --git a/src/other_tools/ops_maps/import_to_git_map.cpp b/src/other_tools/ops_maps/import_to_git_map.cpp index 5c30f3d5..6a998f9d 100644 --- a/src/other_tools/ops_maps/import_to_git_map.cpp +++ b/src/other_tools/ops_maps/import_to_git_map.cpp @@ -32,14 +32,15 @@ void KeepCommitAndSetTree( ImportToGitMap::SetterPtr const& setter, ImportToGitMap::LoggerPtr const& logger) { // Keep tag for commit - GitOpKey op_key = {.params = - { - StorageConfig::GitRoot(), // target_path - commit, // git_hash - "", // branch - "Keep referenced tree alive" // message - }, - .op_type = GitOpType::KEEP_TAG}; + GitOpKey op_key = { + .params = + { + StorageConfig::Instance().GitRoot(), // target_path + commit, // git_hash + "", // branch + "Keep referenced tree alive" // message + }, + .op_type = GitOpType::KEEP_TAG}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -132,11 +133,11 @@ auto CreateImportToGitMap( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare }, .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( @@ -161,11 +162,12 @@ auto CreateImportToGitMap( auto just_git_repo = GitRepoRemote::Open(op_result.git_cas); if (not just_git_repo) { - (*logger)( - fmt::format( - "Could not open Git cache repository {}", - StorageConfig::GitRoot().string()), - /*fatal=*/true); + (*logger)(fmt::format("Could not open Git cache " + "repository {}", + StorageConfig::Instance() + .GitRoot() + .string()), + /*fatal=*/true); return; } auto wrapped_logger = @@ -207,7 +209,7 @@ auto CreateImportToGitMap( setter, wrapped_logger); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git " "op ENSURE_INIT bare for " diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index 18d80aa7..7d74dc43 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -51,7 +51,8 @@ namespace { [[nodiscard]] auto IsCacheGitRoot( std::filesystem::path const& repo_root) noexcept -> bool { return std::filesystem::absolute(ToNormalPath(repo_root)) == - std::filesystem::absolute(ToNormalPath(StorageConfig::GitRoot())); + std::filesystem::absolute( + ToNormalPath(StorageConfig::Instance().GitRoot())); } /// \brief Helper function for ensuring the serve endpoint, if given, has the @@ -161,7 +162,7 @@ void WriteIdFileAndSetWSRoot(std::string const& root_tree_id, auto git_repo = GitRepoRemote::Open(git_cas); // link fake repo to odb if (not git_repo) { (*logger)(fmt::format("Could not open cache object database {}", - StorageConfig::GitRoot().string()), + StorageConfig::Instance().GitRoot().string()), /*fatal=*/true); return; } @@ -184,7 +185,7 @@ void WriteIdFileAndSetWSRoot(std::string const& root_tree_id, ? FileRoot::kGitTreeIgnoreSpecialMarker : FileRoot::kGitTreeMarker, *tree_id, - StorageConfig::GitRoot().string()}), + StorageConfig::Instance().GitRoot().string()}), false)); } @@ -447,18 +448,21 @@ void EnsureCommit(GitRepoInfo const& repo_info, /*fatal=*/true); return; } - auto just_git_cas = GitCAS::Open(StorageConfig::GitRoot()); + auto just_git_cas = + GitCAS::Open(StorageConfig::Instance().GitRoot()); if (not just_git_cas) { - (*logger)(fmt::format("Could not open Git cache database {}", - StorageConfig::GitRoot().string()), - /*fatal=*/true); + (*logger)( + fmt::format("Could not open Git cache database {}", + StorageConfig::Instance().GitRoot().string()), + /*fatal=*/true); return; } auto just_git_repo = GitRepo::Open(just_git_cas); if (not just_git_repo) { - (*logger)(fmt::format("Could not open Git cache repository {}", - StorageConfig::GitRoot().string()), - /*fatal=*/true); + (*logger)( + fmt::format("Could not open Git cache repository {}", + StorageConfig::Instance().GitRoot().string()), + /*fatal=*/true); return; } // extract the subdir tree @@ -481,7 +485,7 @@ void EnsureCommit(GitRepoInfo const& repo_info, if (repo_info.absent and not fetch_absent) { // try by all available means to generate & set the absent root EnsureRootAsAbsent(*tree_id, - StorageConfig::GitRoot(), + StorageConfig::Instance().GitRoot(), repo_info, serve, remote_api, @@ -490,14 +494,14 @@ void EnsureCommit(GitRepoInfo const& repo_info, } else { // this root is present - (*ws_setter)( - std::pair(nlohmann::json::array( - {repo_info.ignore_special - ? FileRoot::kGitTreeIgnoreSpecialMarker - : FileRoot::kGitTreeMarker, - *tree_id, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/false)); + (*ws_setter)(std::pair( + nlohmann::json::array( + {repo_info.ignore_special + ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + *tree_id, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/false)); } // done! return; @@ -546,16 +550,16 @@ void EnsureCommit(GitRepoInfo const& repo_info, if (serve_result) { auto const& root_tree_id = *serve_result; // verify if we know the tree already in the local Git cache - GitOpKey op_key = { - .params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = {.params = + { + StorageConfig::Instance() + .GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -586,12 +590,13 @@ void EnsureCommit(GitRepoInfo const& repo_info, auto just_git_repo = GitRepoRemote::Open(op_result.git_cas); if (not just_git_repo) { - (*logger)( - fmt::format( - "Could not open Git cache repository " - "{}", - StorageConfig::GitRoot().string()), - /*fatal=*/true); + (*logger)(fmt::format("Could not open Git " + "cache repository " + "{}", + StorageConfig::Instance() + .GitRoot() + .string()), + /*fatal=*/true); return; } // check tree existence @@ -604,7 +609,8 @@ void EnsureCommit(GitRepoInfo const& repo_info, "While verifying presence of " "tree {} in repository {}:\n{}", tree, - StorageConfig::GitRoot() + StorageConfig::Instance() + .GitRoot() .string(), msg), fatal); @@ -721,8 +727,9 @@ void EnsureCommit(GitRepoInfo const& repo_info, JustMRProgress::Instance().TaskTracker().Stop( repo_info.origin); // Move tree from local CAS to local Git storage - auto tmp_dir = StorageConfig::CreateTypedTmpDir( - "fetch-absent-root"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir( + "fetch-absent-root"); if (not tmp_dir) { (*logger)( fmt::format( @@ -825,7 +832,8 @@ void EnsureCommit(GitRepoInfo const& repo_info, ws_setter, logger); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, + target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git " "op ENSURE_INIT bare for " diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index c55e0064..9c7e2cee 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -116,7 +116,7 @@ void EnsureRootAsAbsent(std::string const& tree_id, if (not EnsureAbsentRootOnServe( *serve, tree_id, - StorageConfig::GitRoot(), + StorageConfig::Instance().GitRoot(), remote_api, logger, /*no_sync_is_fatal=*/true)) { @@ -139,12 +139,13 @@ void EnsureRootAsAbsent(std::string const& tree_id, // the tree is known locally, so we can upload it to remote // CAS for the serve endpoint to retrieve it and set up the // root - if (not EnsureAbsentRootOnServe(*serve, - tree_id, - StorageConfig::GitRoot(), - remote_api, - logger, - /*no_sync_is_fatal=*/true)) { + if (not EnsureAbsentRootOnServe( + *serve, + tree_id, + StorageConfig::Instance().GitRoot(), + remote_api, + logger, + /*no_sync_is_fatal=*/true)) { return; } } @@ -205,9 +206,10 @@ void ResolveContentTree( } else { (*ws_setter)(std::pair( - nlohmann::json::array({FileRoot::kGitTreeMarker, - *resolved_tree_id, - StorageConfig::GitRoot().string()}), + nlohmann::json::array( + {FileRoot::kGitTreeMarker, + *resolved_tree_id, + StorageConfig::Instance().GitRoot().string()}), /*is_cache_hit=*/is_cache_hit)); } } @@ -257,7 +259,8 @@ void ResolveContentTree( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path + StorageConfig::Instance() + .GitRoot(), // target_path resolved_tree_id, // git_hash "", // branch "Keep referenced tree alive" // message @@ -303,15 +306,18 @@ void ResolveContentTree( logger); } else { - (*ws_setter)(std::pair( - nlohmann::json::array( - {FileRoot::kGitTreeMarker, - resolved_tree_id, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/is_cache_hit)); + (*ws_setter)( + std::pair(nlohmann::json::array( + {FileRoot::kGitTreeMarker, + resolved_tree_id, + StorageConfig::Instance() + .GitRoot() + .string()}), + /*is_cache_hit=*/is_cache_hit)); } }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, + target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)( fmt::format("While running critical Git op " @@ -343,11 +349,12 @@ void ResolveContentTree( logger); } else { - (*ws_setter)(std::pair( - nlohmann::json::array({FileRoot::kGitTreeMarker, - tree_hash, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/is_cache_hit)); + (*ws_setter)( + std::pair(nlohmann::json::array( + {FileRoot::kGitTreeMarker, + tree_hash, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/is_cache_hit)); } } } @@ -431,7 +438,7 @@ void ExtractAndImportToGit( ContentGitMap::SetterPtr const& setter, ContentGitMap::LoggerPtr const& logger) { // extract archive - auto tmp_dir = StorageConfig::CreateTypedTmpDir(key.repo_type); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir(key.repo_type); if (not tmp_dir) { (*logger)(fmt::format("Failed to create tmp path for {} target {}", key.repo_type, @@ -538,15 +545,16 @@ auto CreateContentGitMap( } // ensure Git cache // define Git operation to be done - GitOpKey op_key = {.params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = { + .params = + { + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -605,7 +613,7 @@ auto CreateContentGitMap( setter, logger); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git " "op ENSURE_INIT for " @@ -678,11 +686,11 @@ auto CreateContentGitMap( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare }, .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( @@ -808,7 +816,7 @@ auto CreateContentGitMap( key.archive.content), /*fatal=*/true); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git op " "ENSURE_INIT for target {}:\n{}", diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp index 5371b359..4bfb32ca 100644 --- a/src/other_tools/root_maps/distdir_git_map.cpp +++ b/src/other_tools/root_maps/distdir_git_map.cpp @@ -70,7 +70,7 @@ void ImportFromCASAndSetRoot( DistdirGitMap::SetterPtr const& setter, DistdirGitMap::LoggerPtr const& logger) { // create the links to CAS - auto tmp_dir = StorageConfig::CreateTypedTmpDir("distdir"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("distdir"); if (not tmp_dir) { (*logger)(fmt::format("Failed to create tmp path for " "distdir target {}", @@ -111,11 +111,12 @@ void ImportFromCASAndSetRoot( return; } // set the workspace root as present - (*setter)(std::pair( - nlohmann::json::array({FileRoot::kGitTreeMarker, - distdir_tree_id, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/false)); + (*setter)( + std::pair(nlohmann::json::array( + {FileRoot::kGitTreeMarker, + distdir_tree_id, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/false)); }, [logger, target_path = tmp_dir->GetPath()](auto const& msg, bool fatal) { @@ -160,15 +161,16 @@ auto CreateDistdirGitMap( } // ensure Git cache // define Git operation to be done - GitOpKey op_key = {.params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = { + .params = + { + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -250,7 +252,7 @@ auto CreateDistdirGitMap( if (not EnsureAbsentRootOnServe( *serve, distdir_tree_id, - StorageConfig::GitRoot(), + StorageConfig::Instance().GitRoot(), remote_api, logger, true /*no_sync_is_fatal*/)) { @@ -275,15 +277,15 @@ auto CreateDistdirGitMap( } else { // set root as present - (*setter)( - std::pair(nlohmann::json::array( - {FileRoot::kGitTreeMarker, - distdir_tree_id, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/true)); + (*setter)(std::pair( + nlohmann::json::array( + {FileRoot::kGitTreeMarker, + distdir_tree_id, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/true)); } }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)(fmt::format("While running critical Git op " "ENSURE_INIT for target {}:\n{}", diff --git a/src/other_tools/root_maps/foreign_file_git_map.cpp b/src/other_tools/root_maps/foreign_file_git_map.cpp index 1baa2af2..cf3690f3 100644 --- a/src/other_tools/root_maps/foreign_file_git_map.cpp +++ b/src/other_tools/root_maps/foreign_file_git_map.cpp @@ -43,11 +43,11 @@ void WithRootImportedToGit(ForeignFileInfo const& key, fmt::format("Failed to write cache file {}", tree_id_file.string()), /*fatal=*/false); } - (*setter)( - std::pair(nlohmann::json::array({FileRoot::kGitTreeMarker, - result.first, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/false)); + (*setter)(std::pair( + nlohmann::json::array({FileRoot::kGitTreeMarker, + result.first, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/false)); } void WithFetchedFile(ForeignFileInfo const& key, @@ -55,7 +55,7 @@ void WithFetchedFile(ForeignFileInfo const& key, gsl::not_null<TaskSystem*> const& ts, ForeignFileGitMap::SetterPtr const& setter, ForeignFileGitMap::LoggerPtr const& logger) { - auto tmp_dir = StorageConfig::CreateTypedTmpDir("foreign-file"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("foreign-file"); auto const& cas = Storage::Instance().CAS(); auto digest = ArtifactDigest(key.archive.content, 0, key.executable); auto content_cas_path = cas.BlobPath(digest, key.executable); @@ -105,11 +105,11 @@ void UseCacheHit(const std::string& tree_id, // We keep the invariant, that, whenever a cache entry is written, // the root is in our git root; in particular, the latter is present, // initialized, etc; so we can directly write the result. - (*setter)( - std::pair(nlohmann::json::array({FileRoot::kGitTreeMarker, - tree_id, - StorageConfig::GitRoot().string()}), - /*is_cache_hit=*/true)); + (*setter)(std::pair( + nlohmann::json::array({FileRoot::kGitTreeMarker, + tree_id, + StorageConfig::Instance().GitRoot().string()}), + /*is_cache_hit=*/true)); } void HandleAbsentForeignFile(ForeignFileInfo const& key, diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp index 3f47d237..65716b5c 100644 --- a/src/other_tools/root_maps/fpath_git_map.cpp +++ b/src/other_tools/root_maps/fpath_git_map.cpp @@ -123,7 +123,7 @@ void ResolveFilePathTree( // available to be able to build against it; the tree is resolved, // so it is in our Git cache CheckServeAndSetRoot(*resolved_tree_id, - StorageConfig::GitRoot().string(), + StorageConfig::Instance().GitRoot().string(), absent, serve, remote_api, @@ -174,7 +174,8 @@ void ResolveFilePathTree( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path + StorageConfig::Instance() + .GitRoot(), // target_path resolved_tree_id, // git_hash "", // branch "Keep referenced tree alive" // message @@ -212,14 +213,15 @@ void ResolveFilePathTree( // it; the resolved tree is in the Git cache CheckServeAndSetRoot( resolved_tree_id, - StorageConfig::GitRoot().string(), + StorageConfig::Instance().GitRoot().string(), absent, serve, remote_api, ws_setter, logger); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, + target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)( fmt::format("While running critical Git op " @@ -341,16 +343,16 @@ auto CreateFilePathGitMap( // resolve tree and set workspace root; tree gets resolved // from source repo into the Git cache, which we first need // to ensure is initialized - GitOpKey op_key = { - .params = - { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare - }, - .op_type = GitOpType::ENSURE_INIT}; + GitOpKey op_key = {.params = + { + StorageConfig::Instance() + .GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare + }, + .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( ts, {std::move(op_key)}, @@ -390,7 +392,8 @@ auto CreateFilePathGitMap( setter, logger); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, + target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)( fmt::format("While running critical Git op " @@ -423,7 +426,7 @@ auto CreateFilePathGitMap( /*fatal=*/false); } // it's not a git repo, so import it to git cache - auto tmp_dir = StorageConfig::CreateTypedTmpDir("file"); + auto tmp_dir = StorageConfig::Instance().CreateTypedTmpDir("file"); if (not tmp_dir) { (*logger)("Failed to create import-to-git tmp directory!", /*fatal=*/true); @@ -466,20 +469,21 @@ auto CreateFilePathGitMap( std::string tree = values[0]->first; // resolve tree and set workspace root; // we work on the Git CAS directly - ResolveFilePathTree(StorageConfig::GitRoot().string(), - fpath.string(), - tree, - pragma_special, - values[0]->second, /*source_cas*/ - values[0]->second, /*target_cas*/ - absent, - critical_git_op_map, - resolve_symlinks_map, - serve, - remote_api, - ts, - setter, - logger); + ResolveFilePathTree( + StorageConfig::Instance().GitRoot().string(), + fpath.string(), + tree, + pragma_special, + values[0]->second, /*source_cas*/ + values[0]->second, /*target_cas*/ + absent, + critical_git_op_map, + resolve_symlinks_map, + serve, + remote_api, + ts, + setter, + logger); }, [logger, target_path = key.fpath](auto const& msg, bool fatal) { (*logger)( diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp index b6bf3a22..80f3d075 100644 --- a/src/other_tools/root_maps/tree_id_git_map.cpp +++ b/src/other_tools/root_maps/tree_id_git_map.cpp @@ -35,7 +35,7 @@ void UploadToServeAndSetRoot(ServeApi const& serve, TreeIdGitMap::LoggerPtr const& logger) { // upload to remote CAS auto repo_config = RepositoryConfig{}; - if (repo_config.SetGitCAS(StorageConfig::GitRoot())) { + if (repo_config.SetGitCAS(StorageConfig::Instance().GitRoot())) { auto git_api = GitApi{&repo_config}; if (not git_api.RetrieveToCas( {Artifact::ObjectInfo{.digest = digest, @@ -50,7 +50,7 @@ void UploadToServeAndSetRoot(ServeApi const& serve, } else { (*logger)(fmt::format("Failed to SetGitCAS at {}", - StorageConfig::GitRoot().string()), + StorageConfig::Instance().GitRoot().string()), /*fatal=*/true); return; } @@ -86,7 +86,8 @@ void MoveCASTreeToGitAndProcess( TreeIdGitMap::SetterPtr const& setter, TreeIdGitMap::LoggerPtr const& logger) { // Move tree from CAS to local Git storage - auto tmp_dir = StorageConfig::CreateTypedTmpDir("fetch-remote-git-tree"); + auto tmp_dir = + StorageConfig::Instance().CreateTypedTmpDir("fetch-remote-git-tree"); if (not tmp_dir) { (*logger)(fmt::format("Failed to create tmp directory for copying " "git-tree {} from remote CAS", @@ -228,11 +229,11 @@ auto CreateTreeIdGitMap( GitOpKey op_key = { .params = { - StorageConfig::GitRoot(), // target_path - "", // git_hash - "", // branch - std::nullopt, // message - true // init_bare + StorageConfig::Instance().GitRoot(), // target_path + "", // git_hash + "", // branch + std::nullopt, // message + true // init_bare }, .op_type = GitOpType::ENSURE_INIT}; critical_git_op_map->ConsumeAfterKeysReady( @@ -261,7 +262,9 @@ auto CreateTreeIdGitMap( if (not git_repo) { (*logger)( fmt::format("Could not open repository {}", - StorageConfig::GitRoot().string()), + StorageConfig::Instance() + .GitRoot() + .string()), /*fatal=*/true); return; } @@ -323,7 +326,7 @@ auto CreateTreeIdGitMap( key.tree_info.hash), /*fatal=*/true); }, - [logger, target_path = StorageConfig::GitRoot()]( + [logger, target_path = StorageConfig::Instance().GitRoot()]( auto const& msg, bool fatal) { (*logger)( fmt::format("While running critical Git op " @@ -359,14 +362,14 @@ auto CreateTreeIdGitMap( // get cache hit info auto is_cache_hit = *values[0]; // set the workspace root as present - (*setter)( - std::pair(nlohmann::json::array( - {key.ignore_special - ? FileRoot::kGitTreeIgnoreSpecialMarker - : FileRoot::kGitTreeMarker, - key.tree_info.hash, - StorageConfig::GitRoot().string()}), - is_cache_hit)); + (*setter)(std::pair( + nlohmann::json::array( + {key.ignore_special + ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + key.tree_info.hash, + StorageConfig::Instance().GitRoot().string()}), + is_cache_hit)); }, [logger, tree_id = key.tree_info.hash](auto const& msg, bool fatal) { |