19 #include <zypp-core/zyppng/pipelines/Expected> 20 #include <zypp-media/FileCheckException> 21 #include <zypp-media/ng/Provide> 23 #include <zypp/ng/Context> 24 #include <zypp/ng/UserRequest> 32 template <
class Executor,
class OpType >
44 : _context(
std::move(zyppContext) )
53 if ( _checksum.empty() ) {
54 MIL <<
"File " <<
_file <<
" has no checksum available." << std::endl;
55 if ( executor()->askUserToAcceptNoDigest(
_file ) ) {
56 MIL <<
"User accepted " <<
_file <<
" with no checksum." << std::endl;
57 return makeReadyResult( expected<void>::success() );
64 return _context->provider()->checksumForFile (
_file, _checksum.type() )
65 | [] ( expected<zypp::CheckSum> sum ) {
71 if ( (real_checksum != _checksum) )
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();
88 else if ( executor()->askUserToAcceptWrongDigest(
_file, _checksum.checksum(), real_checksum.checksum() ) )
90 WAR <<
"User accepted " <<
_file <<
" with WRONG CHECKSUM." << std::endl;
91 exceptions[real_checksum.checksum()] = _checksum.checksum();
93 return expected<void>::success();
100 return expected<void>::success();
119 _context->sendUserRequest( req );
120 return req->choice ();
125 _context->sendUserRequest( req );
126 return req->choice ();
131 _context->sendUserRequest( req );
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|;
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|;
187 | [ res ] ( expected<void> result )
mutable {
189 return expected<SyncProvideRes>::success( std::move(res) );
191 return expected<SyncProvideRes>::error( std::move(result.error()) );
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
std::function< AsyncOpRef< expected< ProvideRes > >ProvideRes &&)> checksumFileChecker(ContextRef zyppCtx, zypp::CheckSum checksum)
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
UserData makeData(const zypp::Pathname &p, const std::string &name)
String related utilities and Regular expression matching.
zypp::CheckSum checksumFromFile(SyncContextRef &, const zypp::Pathname &path, const std::string &checksumType)
std::string basename() const
Return the last component of this path.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
ZyppContextRefType _context
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
static std::enable_if_t< detail::is_async_op_v< FOpType >, AsyncOpRef< Result > > run(Args &&...args)
Store and operate on date (time_t).
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
typename ProvideType::Res ProvideRes
typename ZyppContextType::ProvideType ProvideType
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
bool askUserToAcceptNoDigest(const zypp::Pathname &file)
bool askUserToAcceptWrongDigest(const zypp::Pathname &file, const std::string &requested, const std::string &found)
static const ValueType hour
bool askUserToAccepUnknownDigest(const zypp::Pathname &file, const std::string &name)
static Date now()
Return the current time.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
expected< void > verifyChecksum(SyncContextRef zyppCtx, zypp::CheckSum checksum, zypp::Pathname file)
UserData makeData(const zypp::Pathname &p)
typename ProvideType::MediaHandle MediaHandle
std::conditional_t< detail::is_async_op_v< OpType >, ContextRef, SyncContextRef > MaybeAsyncContextRef
UserData makeData(const zypp::Pathname &p, const std::string &requested, const std::string &found)
CheckSumWorkflowLogic(ZyppContextRefType zyppContext, zypp::CheckSum &&checksum, zypp::Pathname file)
remove_smart_ptr_t< ZyppContextRefType > ZyppContextType