---
Note: this changes the abi, so a version bump is in order.
zypp/Fetcher.cc | 52 ++++++++++++++++++++++++++++++++++------------------
zypp/Fetcher.h | 17 +++++++++++++----
2 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/zypp/Fetcher.cc b/zypp/Fetcher.cc
index 14b2325..c0c9820 100644
--- a/zypp/Fetcher.cc
+++ b/zypp/Fetcher.cc
@@ -88,6 +88,7 @@ namespace zypp
// check checksums even if there is no such
// checksum (warns of no checksum)
AlwaysVerifyChecksum = 0x0004,
+ Cancelled = 0x0008,
};
ZYPP_DECLARE_FLAGS(Flags, Flag);
@@ -111,7 +112,6 @@ namespace zypp
};
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(FetcherJob::Flags);
- typedef shared_ptr<FetcherJob> FetcherJob_Ptr;
std::ostream & operator<<( std::ostream & str, const FetcherJob_Ptr & obj )
{
@@ -137,12 +137,13 @@ namespace zypp
void addIndex( const OnMediaLocation &resource );
- void enqueueDir( const OnMediaLocation &resource, bool recursive, const FileChecker &checker = FileChecker() );
- void enqueueDigestedDir( const OnMediaLocation &resource, bool recursive, const FileChecker &checker = FileChecker() );
+ FetcherJob_Ptr enqueueDir( const OnMediaLocation &resource, bool recursive, const FileChecker &checker = FileChecker() );
+ FetcherJob_Ptr enqueueDigestedDir( const OnMediaLocation &resource, bool recursive, const FileChecker &checker = FileChecker() );
- void enqueue( const OnMediaLocation &resource, const FileChecker &checker = FileChecker() );
- void enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker = FileChecker() );
+ FetcherJob_Ptr enqueue( const OnMediaLocation &resource, const FileChecker &checker = FileChecker() );
+ FetcherJob_Ptr enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker = FileChecker() );
void addCachePath( const Pathname &cache_dir );
+ void cancelJob(FetcherJob_Ptr job);
void reset();
void start( const Pathname &dest_dir,
MediaSetAccess &media,
@@ -232,12 +233,13 @@ namespace zypp
};
///////////////////////////////////////////////////////////////////
- void Fetcher::Impl::enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker )
+ FetcherJob_Ptr Fetcher::Impl::enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker )
{
FetcherJob_Ptr job;
job.reset(new FetcherJob(resource));
job->flags |= FetcherJob:: AlwaysVerifyChecksum;
_resources.push_back(job);
+ return job;
}
Fetcher::Impl::Impl()
@@ -251,7 +253,7 @@ namespace zypp
Fetcher::Options Fetcher::Impl::options() const
{ return _options; }
- void Fetcher::Impl::enqueueDir( const OnMediaLocation &resource,
+ FetcherJob_Ptr Fetcher::Impl::enqueueDir( const OnMediaLocation &resource,
bool recursive,
const FileChecker &checker )
{
@@ -264,9 +266,10 @@ namespace zypp
job->flags |= FetcherJob::Directory;
_resources.push_back(job);
+ return job;
}
- void Fetcher::Impl::enqueueDigestedDir( const OnMediaLocation &resource,
+ FetcherJob_Ptr Fetcher::Impl::enqueueDigestedDir( const OnMediaLocation &resource,
bool recursive,
const FileChecker &checker )
{
@@ -280,16 +283,17 @@ namespace zypp
job->flags |= FetcherJob::AlwaysVerifyChecksum;
_resources.push_back(job);
-
+ return job;
}
- void Fetcher::Impl::enqueue( const OnMediaLocation &resource, const FileChecker &checker )
+ FetcherJob_Ptr Fetcher::Impl::enqueue( const OnMediaLocation &resource, const FileChecker &checker )
{
FetcherJob_Ptr job;
job.reset(new FetcherJob(resource));
if ( checker )
job->checkers.push_back(checker);
_resources.push_back(job);
+ return job;
}
void Fetcher::Impl::addIndex( const OnMediaLocation &resource )
@@ -330,6 +334,11 @@ namespace zypp
}
+ void Fetcher::Impl::cancelJob(FetcherJob_Ptr job)
+ {
+ job->flags |= FetcherJob::Cancelled;
+ }
+
// tries to provide resource to dest_dir from any of the configured additional
// cache paths where the file may already be present. returns true if the
// file was provided from the cache.
@@ -750,6 +759,8 @@ namespace zypp
for ( list