2024-03-30 15:27:55 +00:00
|
|
|
#include "pkg_extractor.hpp"
|
|
|
|
|
2024-07-27 17:52:27 +00:00
|
|
|
PkgExtractor::PkgExtractor(Rust<Pkg> &&pkg, std::string &&dst) :
|
2024-03-30 15:27:55 +00:00
|
|
|
m_pkg(std::move(pkg)),
|
|
|
|
m_dst(std::move(dst))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PkgExtractor::~PkgExtractor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PkgExtractor::exec()
|
|
|
|
{
|
2024-07-27 17:52:27 +00:00
|
|
|
Rust<RustError> e;
|
2024-07-21 10:18:19 +00:00
|
|
|
|
|
|
|
e = pkg_extract(
|
2024-03-30 15:27:55 +00:00
|
|
|
m_pkg,
|
|
|
|
m_dst.c_str(),
|
|
|
|
[](const char *status, std::size_t bar, std::uint64_t current, std::uint64_t total, void *ud) {
|
|
|
|
reinterpret_cast<PkgExtractor *>(ud)->update(status, bar, current, total);
|
|
|
|
},
|
|
|
|
this);
|
|
|
|
|
|
|
|
if (e) {
|
2024-07-21 10:18:19 +00:00
|
|
|
emit finished(error_message(e));
|
2024-03-30 15:27:55 +00:00
|
|
|
} else {
|
|
|
|
emit finished(QString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PkgExtractor::update(const char *status, std::size_t bar, std::uint64_t current, std::uint64_t total)
|
|
|
|
{
|
|
|
|
emit statusChanged(status ? QString(status) : QString(), bar, current, total);
|
|
|
|
}
|