forked from microsoft/vcpkg
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vcpkg] Add experimental x-azblob binary provider (microsoft#13626)
* [vcpkg] Add experimental x-azblob binary provider * [vcpkg] Test azblob storage provider in CI * [vcpkg] Address some CR comments from microsoft#13639 * [vcpkg] Fixup azure-pipelines * [vcpkg] Fix regression where the downloaded package is purged before decompressing * [vcpkg] Further refactor vcpkg::Downloads * [vcpkg] Enable OSX for x-azblob testing * [vcpkg] Reduce diff against master * [vcpkg] Extract Downloads::details::split_uri_view * [vcpkg] Address PR comments * [vcpkg] Add testing and metrics for x-azblob * [vcpkg] Add docs for x-azblob This includes a note that it is currently experimental * [vcpkg] Address CR comments * [vcpkg] Revert pipeline changes except OSX to minimize disruption Co-authored-by: Robert Schumacher <[email protected]> Co-authored-by: Billy Robert O'Neal III <[email protected]>
- Loading branch information
1 parent
9897e27
commit f65bc01
Showing
16 changed files
with
933 additions
and
281 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,16 +1,41 @@ | ||
#pragma once | ||
|
||
#include <vcpkg/base/files.h> | ||
#include <vcpkg/base/optional.h> | ||
#include <vcpkg/base/view.h> | ||
|
||
namespace vcpkg::Downloads | ||
{ | ||
namespace details | ||
{ | ||
struct SplitURIView | ||
{ | ||
StringView scheme; | ||
Optional<StringView> authority; | ||
StringView path_query_fragment; | ||
}; | ||
|
||
// e.g. {"https","//example.org", "/index.html"} | ||
Optional<SplitURIView> split_uri_view(StringView uri); | ||
} | ||
|
||
void verify_downloaded_file_hash(const Files::Filesystem& fs, | ||
const std::string& url, | ||
const fs::path& path, | ||
const std::string& sha512); | ||
|
||
// Returns url that was successfully downloaded from | ||
std::string download_file(Files::Filesystem& fs, | ||
View<std::string> urls, | ||
const fs::path& download_path, | ||
const std::string& sha512); | ||
|
||
void download_file(Files::Filesystem& fs, | ||
const std::string& url, | ||
const fs::path& download_path, | ||
const std::string& sha512); | ||
|
||
std::vector<int> download_files(Files::Filesystem& fs, View<std::pair<std::string, fs::path>> url_pairs); | ||
int put_file(const Files::Filesystem&, StringView url, const fs::path& file); | ||
std::vector<int> url_heads(View<std::string> urls); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
namespace vcpkg::Util | ||
{ | ||
template<class T> | ||
struct LockGuardPtr; | ||
|
||
template<class T> | ||
struct LockGuarded; | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <vcpkg/base/fwd/lockguarded.h> | ||
|
||
#include <mutex> | ||
|
||
namespace vcpkg::Util | ||
{ | ||
template<class T> | ||
struct LockGuarded | ||
{ | ||
friend struct LockGuardPtr<T>; | ||
|
||
LockGuardPtr<T> lock() { return *this; } | ||
|
||
private: | ||
std::mutex m_mutex; | ||
T m_t; | ||
}; | ||
|
||
template<class T> | ||
struct LockGuardPtr | ||
{ | ||
T& operator*() { return m_ptr; } | ||
T* operator->() { return &m_ptr; } | ||
|
||
T* get() { return &m_ptr; } | ||
|
||
LockGuardPtr(LockGuarded<T>& sync) : m_lock(sync.m_mutex), m_ptr(sync.m_t) { } | ||
|
||
private: | ||
std::lock_guard<std::mutex> m_lock; | ||
T& m_ptr; | ||
}; | ||
} |
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <catch2/catch.hpp> | ||
|
||
#include <vcpkg/base/downloads.h> | ||
|
||
using namespace vcpkg; | ||
|
||
TEST_CASE ("Downloads::details::split_uri_view", "[downloads]") | ||
{ | ||
{ | ||
auto x = Downloads::details::split_uri_view("https://github.com/Microsoft/vcpkg"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "https"); | ||
REQUIRE(x.get()->authority.value_or("") == "//github.com"); | ||
REQUIRE(x.get()->path_query_fragment == "/Microsoft/vcpkg"); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view(""); | ||
REQUIRE(!x.has_value()); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("hello"); | ||
REQUIRE(!x.has_value()); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("file:"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "file"); | ||
REQUIRE(!x.get()->authority.has_value()); | ||
REQUIRE(x.get()->path_query_fragment == ""); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("file:path"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "file"); | ||
REQUIRE(!x.get()->authority.has_value()); | ||
REQUIRE(x.get()->path_query_fragment == "path"); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("file:/path"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "file"); | ||
REQUIRE(!x.get()->authority.has_value()); | ||
REQUIRE(x.get()->path_query_fragment == "/path"); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("file://user:pw@host"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "file"); | ||
REQUIRE(x.get()->authority.value_or({}) == "//user:pw@host"); | ||
REQUIRE(x.get()->path_query_fragment == ""); | ||
} | ||
{ | ||
auto x = Downloads::details::split_uri_view("ftp://host:port/"); | ||
REQUIRE(x.has_value()); | ||
REQUIRE(x.get()->scheme == "ftp"); | ||
REQUIRE(x.get()->authority.value_or({}) == "//host:port"); | ||
REQUIRE(x.get()->path_query_fragment == "/"); | ||
} | ||
} |
Oops, something went wrong.