This commit is contained in:
Mars 2025-05-04 17:57:40 -04:00
parent a04a8ea901
commit 2cb836b125
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895

View file

@ -1,8 +1,11 @@
#include "package.hpp" #include "package.hpp"
#include <SQLiteCpp/Database.h> // SQLite::{Database, OPEN_READONLY} #ifndef __serenity__
#include <SQLiteCpp/Exception.h> // SQLite::Exception #include <SQLiteCpp/Database.h> // SQLite::{Database, OPEN_READONLY}
#include <SQLiteCpp/Statement.h> // SQLite::Statement #include <SQLiteCpp/Exception.h> // SQLite::Exception
#include <SQLiteCpp/Statement.h> // SQLite::Statement
#endif // __serenity__
#include <chrono> // std::chrono #include <chrono> // std::chrono
#include <filesystem> // std::filesystem #include <filesystem> // std::filesystem
#include <format> // std::format #include <format> // std::format
@ -137,6 +140,7 @@ namespace package {
return GetCountFromDirectoryImpl(pmId, dirPath, noFilter, false); return GetCountFromDirectoryImpl(pmId, dirPath, noFilter, false);
} }
#ifndef __serenity__
fn GetCountFromDb(const PackageManagerInfo& pmInfo) -> Result<u64, DracError> { fn GetCountFromDb(const PackageManagerInfo& pmInfo) -> Result<u64, DracError> {
const auto& [pmId, dbPath, countQuery] = pmInfo; const auto& [pmId, dbPath, countQuery] = pmInfo;
const String cacheKey = "pkg_count_" + pmId; // More specific cache key const String cacheKey = "pkg_count_" + pmId; // More specific cache key
@ -226,6 +230,7 @@ namespace package {
return count; return count;
} }
#endif // __serenity__
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
fn GetNixCount() -> Result<u64, DracError> { fn GetNixCount() -> Result<u64, DracError> {
@ -246,7 +251,7 @@ namespace package {
return GetCountFromDb(nixInfo); return GetCountFromDb(nixInfo);
} }
#endif #endif // __linux__ || __APPLE__
fn GetCargoCount() -> Result<u64, DracError> { fn GetCargoCount() -> Result<u64, DracError> {
using util::helpers::GetEnv; using util::helpers::GetEnv;
@ -302,7 +307,7 @@ namespace package {
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
futures.push_back(std::async(std::launch::async, GetNixCount)); futures.push_back(std::async(std::launch::async, GetNixCount));
#endif #endif // __linux__ || __APPLE__
futures.push_back(std::async(std::launch::async, GetCargoCount)); futures.push_back(std::async(std::launch::async, GetCargoCount));
u64 totalCount = 0; u64 totalCount = 0;