2 Commits

  1. 19
      libpkg/data/database.cpp
  2. 6
      libpkg/data/database.h
  3. 3
      libpkg/tests/data.cpp
  4. 3
      librepomgr/buildactions/reloadlibrarydependencies.cpp
  5. 3
      librepomgr/webclient/database.cpp
  6. 3
      librepomgr/webclient/database.h
  7. 3
      librepomgr/webclient/session.cpp
  8. 3
      librepomgr/webclient/session.h

19
libpkg/data/database.cpp

@ -499,23 +499,26 @@ LIBPKG_EXPORT void pull<LibPkg::PackageSearchResult>(LibPkg::PackageSearchResult
namespace BinaryReflector {
template <>
LIBPKG_EXPORT void writeCustomType<LibPkg::PackageSearchResult>(BinarySerializer &serializer, const LibPkg::PackageSearchResult &packageSearchResult)
LIBPKG_EXPORT void writeCustomType<LibPkg::PackageSearchResult>(
BinarySerializer &serializer, const LibPkg::PackageSearchResult &packageSearchResult, BinaryVersion version)
{
if (const auto *const dbInfo = std::get_if<LibPkg::DatabaseInfo>(&packageSearchResult.db)) {
serializer.write(dbInfo->name);
serializer.write(dbInfo->name, version);
} else if (const auto *const db = std::get<LibPkg::Database *>(packageSearchResult.db)) {
serializer.write(db->name);
serializer.write(db->name, version);
} else {
serializer.write(std::string());
serializer.write(std::string(), version);
}
serializer.write(packageSearchResult.pkg);
serializer.write(packageSearchResult.pkg, version);
}
template <>
LIBPKG_EXPORT void readCustomType<LibPkg::PackageSearchResult>(BinaryDeserializer &deserializer, LibPkg::PackageSearchResult &packageSearchResult)
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::PackageSearchResult>(
BinaryDeserializer &deserializer, LibPkg::PackageSearchResult &packageSearchResult, BinaryVersion version)
{
deserializer.read(packageSearchResult.db.emplace<LibPkg::DatabaseInfo>().name);
deserializer.read(packageSearchResult.pkg);
deserializer.read(packageSearchResult.db.emplace<LibPkg::DatabaseInfo>().name, version);
deserializer.read(packageSearchResult.pkg, version);
return 0;
}
} // namespace BinaryReflector

6
libpkg/data/database.h

@ -214,9 +214,11 @@ LIBPKG_EXPORT void pull<LibPkg::PackageSearchResult>(LibPkg::PackageSearchResult
namespace BinaryReflector {
template <>
LIBPKG_EXPORT void writeCustomType<LibPkg::PackageSearchResult>(BinarySerializer &serializer, const LibPkg::PackageSearchResult &packageSearchResult);
LIBPKG_EXPORT void writeCustomType<LibPkg::PackageSearchResult>(
BinarySerializer &serializer, const LibPkg::PackageSearchResult &packageSearchResult, BinaryVersion version);
template <>
LIBPKG_EXPORT void readCustomType<LibPkg::PackageSearchResult>(BinaryDeserializer &deserializer, LibPkg::PackageSearchResult &packageSearchResult);
LIBPKG_EXPORT BinaryVersion readCustomType<LibPkg::PackageSearchResult>(
BinaryDeserializer &deserializer, LibPkg::PackageSearchResult &packageSearchResult, BinaryVersion version);
} // namespace BinaryReflector

3
libpkg/tests/data.cpp

@ -181,8 +181,7 @@ void DataTests::testDependencyMatching()
"equal constraint with explicitly specified pkgrel must not match", !pkg3.providesDependency(Dependency::fromString(depStr, 16)));
depStr = "crypto++>=5.6.5-1";
CPPUNIT_ASSERT_MESSAGE(
"greater equal constraint with explicitly specified pkgrel", pkg2.providesDependency(Dependency::fromString(depStr, 17)));
CPPUNIT_ASSERT_MESSAGE("greater equal constraint with explicitly specified pkgrel", pkg2.providesDependency(Dependency::fromString(depStr, 17)));
CPPUNIT_ASSERT_MESSAGE("greater equal constraint, default pkgrel should match", pkg2.providesDependency(Dependency::fromString(depStr, 15)));
CPPUNIT_ASSERT_MESSAGE("greater equal constrainer, any pkgrel should match", pkg3.providesDependency(Dependency::fromString(depStr, 15)));
CPPUNIT_ASSERT_MESSAGE(

3
librepomgr/buildactions/reloadlibrarydependencies.cpp

@ -238,7 +238,8 @@ void LibRepoMgr::ReloadLibraryDependencies::downloadPackagesFromMirror()
m_buildAction->appendOutput(Phrases::SuccessMessage, "Downloading ", packagesWhichNeedCaching, " binary packages from mirror ...\n");
WebClient::cachePackages(m_buildAction->log(),
std::make_shared<WebClient::PackageCachingSession>(m_cachingData, m_setup.building.ioContext, m_setup.webServer.sslContext,
std::bind(&ReloadLibraryDependencies::loadPackageInfoFromContents, this)), m_packageDownloadSizeLimit);
std::bind(&ReloadLibraryDependencies::loadPackageInfoFromContents, this)),
m_packageDownloadSizeLimit);
}
void ReloadLibraryDependencies::loadPackageInfoFromContents()

3
librepomgr/webclient/database.cpp

@ -190,7 +190,8 @@ PackageCachingDataForPackage *PackageCachingSession::getCurrentDataAndSelectNext
return data;
}
void cachePackages(LogContext &log, std::shared_ptr<PackageCachingSession> &&packageCachingSession, std::optional<std::uint64_t> bodyLimit, std::size_t maxParallelDownloads)
void cachePackages(LogContext &log, std::shared_ptr<PackageCachingSession> &&packageCachingSession, std::optional<std::uint64_t> bodyLimit,
std::size_t maxParallelDownloads)
{
for (std::size_t startedDownloads = 0; startedDownloads < maxParallelDownloads; ++startedDownloads) {
auto *const cachingData = packageCachingSession->getCurrentDataAndSelectNext();

3
librepomgr/webclient/database.h

@ -45,7 +45,8 @@ using PackageCachingDataForDatabase = std::unordered_map<std::string_view, Packa
using PackageCachingDataForSession = std::unordered_map<std::string_view, PackageCachingDataForDatabase>;
struct PackageCachingSession;
void cachePackages(LogContext &log, std::shared_ptr<PackageCachingSession> &&packageCachingSession, std::optional<std::uint64_t> bodyLimit = std::nullopt, std::size_t maxParallelDownloads = 8);
void cachePackages(LogContext &log, std::shared_ptr<PackageCachingSession> &&packageCachingSession,
std::optional<std::uint64_t> bodyLimit = std::nullopt, std::size_t maxParallelDownloads = 8);
struct PackageCachingSession : public MultiSession<void> {
friend void cachePackages(LogContext &, std::shared_ptr<PackageCachingSession> &&, std::optional<std::uint64_t>, std::size_t);

3
librepomgr/webclient/session.cpp

@ -41,7 +41,8 @@ void Session::setChunkHandler(ChunkHandler &&handler)
m_chunkProcessing->handler = std::move(handler);
}
void Session::run(const char *host, const char *port, http::verb verb, const char *target, std::optional<std::uint64_t> bodyLimit, unsigned int version)
void Session::run(
const char *host, const char *port, http::verb verb, const char *target, std::optional<std::uint64_t> bodyLimit, unsigned int version)
{
// set SNI Hostname (many hosts need this to handshake successfully)
auto *const sslStream = std::get_if<SslStream>(&m_stream);

3
librepomgr/webclient/session.h

@ -62,7 +62,8 @@ public:
explicit Session(boost::asio::io_context &ioContext, boost::asio::ssl::context &sslContext, Handler &&handler);
void setChunkHandler(ChunkHandler &&handler);
void run(const char *host, const char *port, boost::beast::http::verb verb, const char *target, std::optional<std::uint64_t> bodyLimit = std::nullopt, unsigned int version = 11);
void run(const char *host, const char *port, boost::beast::http::verb verb, const char *target,
std::optional<std::uint64_t> bodyLimit = std::nullopt, unsigned int version = 11);
private:
using RawSocket = boost::asio::ip::tcp::socket;

Loading…
Cancel
Save