diff options
-rw-r--r-- | src/other_tools/ops_maps/repo_fetch_map.cpp | 30 | ||||
-rw-r--r-- | test/end-to-end/just-mr/fetch.sh | 6 |
2 files changed, 28 insertions, 8 deletions
diff --git a/src/other_tools/ops_maps/repo_fetch_map.cpp b/src/other_tools/ops_maps/repo_fetch_map.cpp index 274124a1..e0ff438e 100644 --- a/src/other_tools/ops_maps/repo_fetch_map.cpp +++ b/src/other_tools/ops_maps/repo_fetch_map.cpp @@ -51,13 +51,20 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, auto content_path = casf.BlobPath(ArtifactDigest(content, 0, false)); if (content_path) { - if (not FileSystemManager::CopyFile( - *content_path, fetch_dir / distfile)) { + auto target_name = fetch_dir / distfile; + if (FileSystemManager::Exists(target_name)) { + std::filesystem::permissions( + target_name, + std::filesystem::perms::owner_write, + std::filesystem::perm_options::add); + } + if (not FileSystemManager::CopyFile(*content_path, + target_name)) { (*logger)(fmt::format( "Failed to copy content {} from CAS " - "into fetch directory {}", + "to {}", content, - fetch_dir.string()), + target_name.string()), /*fatal=*/true); return; } @@ -87,12 +94,19 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, auto content_path = casf.BlobPath(ArtifactDigest(key.archive.content, 0, false)); if (content_path) { + auto target_name = fetch_dir / distfile; + if (FileSystemManager::Exists(target_name)) { + std::filesystem::permissions( + target_name, + std::filesystem::perms::owner_write, + std::filesystem::perm_options::add); + } if (not FileSystemManager::CopyFile(*content_path, - fetch_dir / distfile)) { + target_name)) { (*logger)(fmt::format("Failed to copy content {} from CAS " - "into fetch directory {}", + "to {}", key.archive.content, - fetch_dir.string()), + target_name.string()), /*fatal=*/true); return; } @@ -108,4 +122,4 @@ auto CreateRepoFetchMap(gsl::not_null<ContentCASMap*> const& content_cas_map, } }; return AsyncMapConsumer<ArchiveRepoInfo, bool>(fetch_repo, jobs); -}
\ No newline at end of file +} diff --git a/test/end-to-end/just-mr/fetch.sh b/test/end-to-end/just-mr/fetch.sh index 8009f151..8bd78929 100644 --- a/test/end-to-end/just-mr/fetch.sh +++ b/test/end-to-end/just-mr/fetch.sh @@ -67,4 +67,10 @@ newfoocontent=$(git hash-object "${DISTDIR}/foo-1.2.3.tar") echo "Foo archive has now content ${newfoocontent}" test "${newfoocontent}" = "${foocontent}" +# Verify that fetching accepts distfiles already present +"${JUST_MR}" --local-build-root "${LBR}" --distdir "${DISTDIR}" fetch 2>&1 +newfoocontent=$(git hash-object "${DISTDIR}/foo-1.2.3.tar") +echo "Foo archive has now content ${newfoocontent}" +test "${newfoocontent}" = "${foocontent}" + echo OK |