This repository was archived by the owner on Dec 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
try to fix more mirror things #146
Open
wolfv
wants to merge
8
commits into
mamba-org:main
Choose a base branch
from
wolfv:fix_mirror_things
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5535fd8
try to fix more mirror things
wolfv 361910d
rename base_url to mirror_name
wolfv a5639b9
fix test
wolfv dd4d4c5
enforces that targets must have at least one valid mirror associated …
Klaim c3a8ffc
try to correct some file handling stuff
wolfv 6fb9c59
lint
wolfv 372eb22
explicit convert to string
wolfv 7736be8
Merge pull request #1 from Klaim/fix_mirror_things
wolfv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,21 +15,17 @@ namespace powerloader | |
#endif | ||
|
||
DownloadTarget::DownloadTarget(const std::string& path, | ||
const std::string& base_url, | ||
const std::string& mirror_name, | ||
const fs::path& destination) | ||
: m_is_zchunk(ends_with(path, ".zck")) | ||
, m_path(path) | ||
, m_base_url(base_url) | ||
, m_mirror_name(mirror_name) | ||
, m_destination_path(destination) | ||
{ | ||
if (path.find("://") != std::string::npos) | ||
{ | ||
m_complete_url = path; | ||
} | ||
else if (base_url.find("://") != std::string::npos) | ||
{ | ||
m_complete_url = join_url(base_url, path); | ||
} | ||
spdlog::warn("DownloadTarget::DownloadTarget: {}::{} -> {}", | ||
m_mirror_name, | ||
m_path, | ||
destination.string()); | ||
|
||
#if WITH_ZCHUNK | ||
if (m_is_zchunk) | ||
|
@@ -53,16 +49,26 @@ namespace powerloader | |
// we want to create a "mirror" for `http://test.com` to make sure we correctly | ||
// retry and wait on mirror failures | ||
URLHandler uh{ target_url }; | ||
if (uh.scheme() == "file") | ||
{ | ||
spdlog::warn("PATH: {}", uh.path()); | ||
ctx.mirror_map.create_unique_mirror<Mirror>("[file]", ctx, "file://"); | ||
return std::make_shared<DownloadTarget>(uh.path(), "[file]", destination_path); | ||
} | ||
|
||
const std::string url = uh.url(); | ||
const std::string host = hostname_override ? hostname_override.value() : uh.host(); | ||
const std::string path = uh.path(); | ||
const std::string mirror_url = uh.url_without_path(); | ||
const fs::path dst = destination_path.empty() ? fs::path{ rsplit(path, "/", 1).back() } | ||
: destination_path; | ||
|
||
ctx.mirror_map.create_unique_mirror<Mirror>(host, ctx, mirror_url); | ||
spdlog::warn("SETTING MIRRORR >>>> {}, {}", host, mirror_url); | ||
|
||
ctx.mirror_map.create_unique_mirror<Mirror>(mirror_url, ctx, mirror_url); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to be sure: the original code in the |
||
|
||
return std::make_shared<DownloadTarget>(path.substr(1, std::string::npos), host, dst); | ||
return std::make_shared<DownloadTarget>( | ||
path.substr(1, std::string::npos), mirror_url, dst); | ||
} | ||
else | ||
{ | ||
|
@@ -73,7 +79,14 @@ namespace powerloader | |
} | ||
const auto mirror = hostname_override ? hostname_override.value() : parts[0]; | ||
const auto path = parts[1]; | ||
|
||
if (!ctx.mirror_map.has_mirrors(mirror)) | ||
{ | ||
throw std::runtime_error("Mirror " + mirror + " not found"); | ||
} | ||
else | ||
{ | ||
spdlog::warn("Mirror {} already exists", mirror); | ||
} | ||
fs::path dst = destination_path.empty() ? fs::path{ rsplit(path, "/", 1).back() } | ||
: destination_path; | ||
|
||
|
@@ -86,11 +99,6 @@ namespace powerloader | |
|
||
DownloadTarget::~DownloadTarget() = default; | ||
|
||
bool DownloadTarget::has_complete_url() const | ||
{ | ||
return !m_complete_url.empty(); | ||
} | ||
|
||
bool DownloadTarget::validate_checksum(const fs::path& path) | ||
{ | ||
if (m_checksums.empty()) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially voluntarilly didnt expose
begin/end
because that breaks the garantee that the values of the vector are unique (because then we can access and modify the vectors).Suggestions: either
as_map()
which makes a copy, not modifying this container;begin/end
only.