13#include <zypp-core/Date.h>
14#include <zypp-core/Pathname.h>
15#include <zypp-core/CheckSum.h>
16#include <zypp-core/base/Gettext.h>
17#include <zypp-core/fs/PathInfo.h>
19#include <zypp-core/zyppng/pipelines/Expected>
20#include <zypp-media/FileCheckException>
21#include <zypp-media/ng/Provide>
22#include <zypp/Digest.h>
23#include <zypp/ng/Context>
24#include <zypp/ng/UserRequest>
30 using namespace zyppng::operators;
32 template <
class Executor,
class OpType >
54 MIL <<
"File " <<
_file <<
" has no checksum available." << std::endl;
56 MIL <<
"User accepted " <<
_file <<
" with no checksum." << std::endl;
65 | [] ( expected<zypp::CheckSum> sum ) {
76 static std::map<std::string,std::string> exceptions;
82 WAR <<
"File " <<
_file <<
" has wrong checksum " << real_checksum <<
" (expected " <<
_checksum <<
")" << std::endl;
83 if ( !exceptions.empty() && exceptions[real_checksum.checksum()] ==
_checksum.
checksum() )
85 WAR <<
"User accepted " <<
_file <<
" with WRONG CHECKSUM. (remembered)" << std::endl;
86 return expected<void>::success();
90 WAR <<
"User accepted " <<
_file <<
" with WRONG CHECKSUM." << std::endl;
93 return expected<void>::success();
100 return expected<void>::success();
120 return req->choice ();
126 return req->choice ();
132 return req->choice ();
146 return report->askUserToAcceptNoDigest(file);
150 return report->askUserToAccepUnknownDigest( file, name );
154 return report->askUserToAcceptWrongDigest( file, requested, found );
170 using zyppng::operators::operator|;
171 return [ zyppCtx, checksum=std::move(checksum) ](
ProvideRes res )
mutable -> AsyncOpRef<expected<ProvideRes>> {
173 | [ res ] ( expected<void> result )
mutable {
175 return expected<ProvideRes>::success( std::move(res) );
177 return expected<ProvideRes>::error( std::move(result.error()) );
184 using zyppng::operators::operator|;
185 return [ zyppCtx = std::move(zyppCtx), checksum=std::move(checksum) ](
SyncProvideRes res )
mutable -> expected<SyncProvideRes> {
187 | [ res ] ( expected<void> result )
mutable {
189 return expected<SyncProvideRes>::success( std::move(res) );
191 return expected<SyncProvideRes>::error( std::move(result.error()) );
std::string checksum() const
Store and operate on date (time_t).
static const ValueType hour
static Date now()
Return the current time.
std::string basename() const
Return the last component of this path.
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
String related utilities and Regular expression matching.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
UserData makeData(const zypp::Pathname &p)
UserData makeData(const zypp::Pathname &p, const std::string &name)
UserData makeData(const zypp::Pathname &p, const std::string &requested, const std::string &found)
std::function< AsyncOpRef< expected< ProvideRes > >(ProvideRes &&) checksumFileChecker)(ContextRef zyppCtx, zypp::CheckSum checksum)
expected< void > verifyChecksum(SyncContextRef zyppCtx, zypp::CheckSum checksum, zypp::Pathname file)
std::conditional_t< detail::is_async_op_v< OpType >, ContextRef, SyncContextRef > MaybeAsyncContextRef
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
typename ZyppContextType::ProvideType ProvideType
typename ProvideType::MediaHandle MediaHandle
ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
MaybeAsyncContextRef< OpType > ZyppContextRefType
typename ProvideType::Res ProvideRes
ZyppContextRefType _context
remove_smart_ptr_t< ZyppContextRefType > ZyppContextType
CheckSumWorkflowLogic(ZyppContextRefType zyppContext, zypp::CheckSum &&checksum, zypp::Pathname file)
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
zypp::CheckSum checksumFromFile(SyncContextRef &, const zypp::Pathname &path, const std::string &checksumType)
static std::enable_if_t< detail::is_async_op_v< FOpType >, AsyncOpRef< Result > > run(Args &&...args)
auto makeReadyResult(T &&res)
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.