11 #include <zypp-core/zyppng/ui/ProgressObserver> 12 #include <zypp-media/ng/ProvideSpec> 13 #include <zypp/ng/Context> 20 #undef ZYPP_BASE_LOGGER_LOGGROUP 21 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager" 26 template<
typename DlContextRefType,
typename MediaHandle>
27 auto statusLogic( DlContextRefType &&ctx, MediaHandle mediaHandle ) {
28 constexpr
bool isAsync = std::is_same_v<DlContextRefType,repo::AsyncDownloadContextRef>;
31 if ( !mediaHandle.localPath().has_value() ) {
36 const auto &repoInfo = std::forward<DlContextRefType>(ctx)->repoInfo();
44 return statusLogic( std::move(dl), std::move(mediaHandle) );
49 return statusLogic( std::move(dl), std::move(mediaHandle) );
54 template<
typename DlContextRefType,
typename MediaHandle>
55 auto dlLogic( DlContextRefType &&ctx, MediaHandle mediaHandle, ProgressObserverRef progressObserver ) {
57 constexpr
bool isAsync = std::is_same_v<DlContextRefType,repo::AsyncDownloadContextRef>;
62 if ( !mediaHandle.localPath().has_value() ) {
66 if ( progressObserver ) progressObserver->inc();
69 const auto &repoInfo = std::forward<DlContextRefType>(ctx)->repoInfo();
70 auto newstatus =
zypp::RepoStatus( mediaHandle.localPath().value() / repoInfo.path() );
72 zypp::Pathname productpath( std::forward<DlContextRefType>(ctx)->destDir() / repoInfo.path() );
74 newstatus.saveToCookieFile( productpath/
"cookie" );
76 if ( progressObserver ) progressObserver->setFinished();
84 return makeReadyResult<Ret, isAsync>( Ret::success( std::forward<DlContextRefType>(ctx) ) );
90 return dlLogic( std::move(dl), std::move(mediaHandle), std::move(progressObserver) );
95 return dlLogic( std::move(dl), std::move(mediaHandle), std::move(progressObserver) );
zypp::RepoStatus RepoStatus
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > download(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver)
AsyncOpRef< expected< zypp::RepoStatus > > repoStatus(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle)
static expected success(ConsParams &&...params)
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
std::shared_ptr< AsyncOp< T > > AsyncOpRef
Base class for Exception.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.