From 4fe5fc8aec6e391a5e300e234bdc41375bff1d9e Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 5 Apr 2024 11:48:13 +0200 Subject: resolve_symlinks_map: Allow separate source and target repositories In certain cases, e.g., on the serve endpoint, an unresolved tree might lie in a repository other than the Git cache, therefore we cannot create any new entries there, as it would violate our guarantee that we only write under our local build root. Therefore, the resolve_symlinks_map now receives pointers to both the source and target Git databases and ensures that: 1. any tree created on-the-fly is stored exclusively in the target repository, and 2. any other entry required for those trees is made available in the target repository by copying it from the source repository. Note that in our use case the target repository is always our Git cache and passing a pointer to that object database is done to avoid the overhead of otherwise opening the database very often. --- src/other_tools/root_maps/content_git_map.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/other_tools/root_maps/content_git_map.cpp') diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 2a6cad56..d3b0e35b 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -171,6 +171,7 @@ void EnsureRootAsAbsent( void ResolveContentTree( ArchiveRepoInfo const& key, std::string const& tree_hash, + GitCASPtr const& just_git_cas, bool is_cache_hit, bool is_absent, bool serve_api_exists, @@ -212,13 +213,15 @@ void ResolveContentTree( } } else { - // resolve tree + // resolve tree; both source and target repos are the Git cache resolve_symlinks_map->ConsumeAfterKeysReady( ts, {GitObjectToResolve(tree_hash, ".", *key.pragma_special, - /*known_info=*/std::nullopt)}, + /*known_info=*/std::nullopt, + just_git_cas, + just_git_cas)}, [resolve_symlinks_map, tree_hash, tree_id_file, @@ -357,6 +360,7 @@ void WriteIdFileAndSetWSRoot( // resolve tree and set workspace root ResolveContentTree(key, *subtree_hash, + just_git_cas, false, /*is_cache_hit*/ is_absent, serve_api_exists, @@ -543,6 +547,7 @@ auto CreateContentGitMap( ResolveContentTree( key, *subtree_hash, + op_result.git_cas, /*is_cache_hit = */ true, /*is_absent = */ (key.absent and not fetch_absent), serve_api_exists, -- cgit v1.2.3