Author: dmacvicar
Date: Sun Jun 17 18:05:12 2007
New Revision: 5761
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5761&view=rev
Log:
- add progress hook to all time consuming tasks in repo manager.
- start prototyping a sub-task progress handler in my devel dir
Modified:
trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt
trunk/libzypp/devel/devel.dmacvicar/SUSETagsDownloader_tp.cc
trunk/libzypp/devel/devel.dmacvicar/YUMDownloader_tp.cc
trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc
trunk/libzypp/devel/devel.dmacvicar/testbed.cc
trunk/libzypp/zypp/Fetcher.cc
trunk/libzypp/zypp/Fetcher.h
trunk/libzypp/zypp/RepoManager.cc
trunk/libzypp/zypp/RepoManager.h
trunk/libzypp/zypp/cache/CacheStore.cc
trunk/libzypp/zypp/cache/CacheStore.h
trunk/libzypp/zypp/repo/susetags/Downloader.cc
trunk/libzypp/zypp/repo/susetags/Downloader.h
trunk/libzypp/zypp/repo/yum/Downloader.cc
trunk/libzypp/zypp/repo/yum/Downloader.h
Modified: trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt (original)
+++ trunk/libzypp/devel/devel.dmacvicar/CMakeLists.txt Sun Jun 17 18:05:12 2007
@@ -11,27 +11,21 @@
ADD_EXECUTABLE(cachestore CacheStore_tp.cc)
TARGET_LINK_LIBRARIES(cachestore zypp )
-TARGET_LINK_LIBRARIES(cachestore zypp2 )
ADD_EXECUTABLE(testbed testbed.cc)
TARGET_LINK_LIBRARIES(testbed zypp )
-TARGET_LINK_LIBRARIES(testbed zypp2 )
ADD_EXECUTABLE(yum-downloader YUMDownloader_tp.cc)
TARGET_LINK_LIBRARIES(yum-downloader zypp )
-TARGET_LINK_LIBRARIES(yum-downloader zypp2 )
-ADD_EXECUTABLE(yum-reader YUMReader_tp.cc)
-TARGET_LINK_LIBRARIES(yum-reader zypp )
-TARGET_LINK_LIBRARIES(yum-reader zypp2 )
+# ADD_EXECUTABLE(yum-reader YUMReader_tp.cc)
+# TARGET_LINK_LIBRARIES(yum-reader zypp )
ADD_EXECUTABLE(cachedsource CachedSource_tp.cc)
TARGET_LINK_LIBRARIES(cachedsource zypp )
-TARGET_LINK_LIBRARIES(cachedsource zypp2 )
ADD_EXECUTABLE(repomanager RepositoryManager_tp.cc)
TARGET_LINK_LIBRARIES(repomanager zypp )
-TARGET_LINK_LIBRARIES(repomanager zypp2 )
FIND_PACKAGE(Zsync)
IF(ZSYNC_FOUND)
Modified: trunk/libzypp/devel/devel.dmacvicar/SUSETagsDownloader_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/SUSETagsDownloader_tp.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/SUSETagsDownloader_tp.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/SUSETagsDownloader_tp.cc Sun Jun 17 18:05:12 2007
@@ -15,7 +15,7 @@
#include
#include
#include
-#include
+#include
#include
#include "zypp/Product.h"
@@ -25,7 +25,7 @@
using namespace std;
using namespace zypp;
using namespace media;
-using namespace source::susetags;
+using namespace repo::susetags;
int main(int argc, char **argv)
{
@@ -36,7 +36,7 @@
try
{
ZYpp::Ptr z = getZYpp();
- SUSETagsDownloader downloader(Url(argv[1]), "/");
+ Downloader downloader(Url(argv[1]), "/");
downloader.download(argv[2]);
}
catch ( const Exception &e )
Modified: trunk/libzypp/devel/devel.dmacvicar/YUMDownloader_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/YUMDownloader_tp.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/YUMDownloader_tp.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/YUMDownloader_tp.cc Sun Jun 17 18:05:12 2007
@@ -15,7 +15,7 @@
#include "zypp/MediaSetAccess.h"
#include "zypp/source/SUSEMediaVerifier.h"
#include "zypp/OnMediaLocation.h"
-#include "zypp/source/yum/YUMDownloader.h"
+#include "zypp/repo/yum/Downloader.h"
#include "zypp/Fetcher.h"
#include "zypp/Product.h"
@@ -25,7 +25,7 @@
using namespace std;
using namespace zypp;
using namespace media;
-using namespace source::yum;
+using namespace repo::yum;
int main(int argc, char **argv)
{
@@ -36,7 +36,7 @@
try
{
ZYpp::Ptr z = getZYpp();
- YUMDownloader downloader(Url(argv[1]), "/");
+ Downloader downloader(Url(argv[1]), "/");
downloader.download(argv[2]);
}
catch ( const Exception &e )
Modified: trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/YUMReader_tp.cc Sun Jun 17 18:05:12 2007
@@ -6,7 +6,7 @@
#include "zypp/data/ResolvableDataConsumer.h"
#include "zypp/base/Measure.h"
#include "zypp/detail/ResObjectFactory.h"
-#include "zypp/parser/yum/YUMParser.h"
+#include "zypp/parser/yum/RepoParser.h"
#include "zypp/repo/memory/PackageImpl.h"
@@ -122,7 +122,7 @@
MIL << "creating PrimaryFileParser" << endl;
Measure parse_primary_timer("primary.xml.gz parsing");
ResolvableConsumer store;
- parser::yum::YUMParser parser( 0, store, &progress_function);
+ parser::yum::RepoParser parser( 0, store, &progress_function);
parser.parse(argv[1]);
parse_primary_timer.stop();
Modified: trunk/libzypp/devel/devel.dmacvicar/testbed.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.dmacvicar/testbed.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/devel/devel.dmacvicar/testbed.cc (original)
+++ trunk/libzypp/devel/devel.dmacvicar/testbed.cc Sun Jun 17 18:05:12 2007
@@ -14,21 +14,103 @@
#include "zypp/repo/cached/RepoImpl.h"
#include "zypp/data/ResolvableData.h"
+#include "zypp/TmpPath.h"
+#include "zypp/ProgressData.h"
+#include "zypp/parser/yum/RepoParser.h"
+#include "zypp/repo/yum/Downloader.h"
+
using namespace std;
using namespace zypp;
using namespace zypp::repo;
using namespace zypp::repo::cached;
+bool task_receiver( ProgressData::value_type v )
+{
+ cout << "got ->" << v << endl;
+ return( v <= 100 ); // Abort if ( v > 100 )
+}
+
+struct ProgressDataWrapper
+{
+ ProgressDataWrapper( ProgressData &pd,
+ ProgressData::value_type percentage )
+ : _percentage(percentage),
+ _last_value(0),
+ _pd(pd)
+
+ {
+
+ }
+
+ bool operator()( ProgressData::value_type v )
+ {
+ MIL << endl;
+ ProgressData::value_type increment = v - _last_value;
+ int real_increment = (int)((float)(_percentage*increment)/100);
+ MIL << "Value: " << v << ". Increment of " << increment << ". Real of " << real_increment << endl;
+ _last_value = v;
+ return _pd.incr(real_increment);
+ }
+
+ ProgressData::value_type _percentage;
+ ProgressData::value_type _last_value;
+ ProgressData &_pd;
+};
+
+// task one is 80%
+void small_task_one( ProgressData::ReceiverFnc rcv )
+{
+ MIL << "Small task one" << endl;
+ ProgressData progress(100);
+ progress.sendTo(rcv);
+ progress.toMin();
+ progress.set(10);
+ progress.set(20);
+ progress.set(30);
+ progress.set(40);
+ progress.set(70);
+ progress.toMax();
+}
+
+// task one is 20%
+void small_task_two( ProgressData::ReceiverFnc rcv )
+{
+ MIL << "Small task two" << endl;
+ ProgressData progress(100);
+ progress.sendTo(rcv);
+ progress.toMin();
+ progress.set(10);
+ progress.set(20);
+ progress.set(70);
+ progress.toMax();
+}
+
+
+void big_task( ProgressData::ReceiverFnc rcv )
+{
+ ProgressData progress(100);
+ progress.sendTo(rcv);
+ progress.toMin();
+ ProgressDataWrapper wrapper1( progress, 80 );
+ small_task_one( wrapper1 );
+ ProgressDataWrapper wrapper2( progress, 20 );
+ small_task_two( wrapper2 );
+ progress.toMax();
+}
int main(int argc, char **argv)
{
try
{
- ZYpp::Ptr z = getZYpp();
+ //ZYpp::Ptr z = getZYpp();
- z->initializeTarget("/");
- ResStore res = z->target()->resolvables();
- MIL << res.size() << " resolvables" << endl;
+ //z->initializeTarget("/");
+// filesystem::TmpDir tmpdir;
+// yum::Downloader downloader(Url("http://ftp.gwdg.de/pub/suse/update/10.2"), "/");
+// downloader.download(tmpdir.path(), &yum_download_receiver);
+ big_task(&task_receiver);
+ //ResStore res = z->target()->resolvables();
+ //MIL << res.size() << " resolvables" << endl;
}
catch ( const Exception &e )
Modified: trunk/libzypp/zypp/Fetcher.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Fetcher.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/Fetcher.cc (original)
+++ trunk/libzypp/zypp/Fetcher.cc Sun Jun 17 18:05:12 2007
@@ -15,6 +15,7 @@
#include "zypp/base/Logger.h"
#include "zypp/base/DefaultIntegral.h"
#include "zypp/Fetcher.h"
+#include "zypp/base/UserRequestException.h"
using namespace std;
@@ -52,7 +53,9 @@
void enqueueDigested( const OnMediaLocation &resource, const FileChecker &checker );
void addCachePath( const Pathname &cache_dir );
void reset();
- void start( const Pathname &dest_dir, MediaSetAccess &media );
+ void start( const Pathname &dest_dir,
+ MediaSetAccess &media,
+ const ProgressData::ReceiverFnc & progress_receiver );
/** Offer default Impl. */
static shared_ptr<Impl> nullimpl()
@@ -99,8 +102,13 @@
_caches.push_back(cache_dir);
}
- void Fetcher::Impl::start( const Pathname &dest_dir, MediaSetAccess &media )
+ void Fetcher::Impl::start( const Pathname &dest_dir,
+ MediaSetAccess &media,
+ const ProgressData::ReceiverFnc & progress_receiver )
{
+ ProgressData progress(_resources.size());
+ progress.sendTo(progress_receiver);
+
for ( list<FetcherJob>::const_iterator it_res = _resources.begin(); it_res != _resources.end(); ++it_res )
{
bool got_from_cache = false;
@@ -201,6 +209,9 @@
{
ZYPP_THROW(Exception("Unknown error while validating " + (*it_res).location.filename().asString()));
}
+
+ if ( ! progress.incr() )
+ ZYPP_THROW(AbortRequestException());
} // for each job
}
@@ -253,9 +264,11 @@
_pimpl->reset();
}
- void Fetcher::start( const Pathname &dest_dir, MediaSetAccess &media )
+ void Fetcher::start( const Pathname &dest_dir,
+ MediaSetAccess &media,
+ const ProgressData::ReceiverFnc & progress_receiver )
{
- _pimpl->start(dest_dir, media);
+ _pimpl->start(dest_dir, media, progress_receiver);
}
Modified: trunk/libzypp/zypp/Fetcher.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Fetcher.h?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/Fetcher.h (original)
+++ trunk/libzypp/zypp/Fetcher.h Sun Jun 17 18:05:12 2007
@@ -22,6 +22,7 @@
#include "zypp/Digest.h"
#include "zypp/MediaSetAccess.h"
#include "zypp/FileChecker.h"
+#include "zypp/ProgressData.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -112,7 +113,9 @@
* directory
*
*/
- void start( const Pathname &dest_dir, MediaSetAccess &media );
+ void start( const Pathname &dest_dir,
+ MediaSetAccess &media,
+ const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
private:
/** Pointer to implementation */
Modified: trunk/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.cc (original)
+++ trunk/libzypp/zypp/RepoManager.cc Sun Jun 17 18:05:12 2007
@@ -44,6 +44,24 @@
namespace zypp
{ /////////////////////////////////////////////////////////////////
+// class SubJobReceiverFnc
+// {
+// SubJobReceiverFnc( ProgressData::value_type jobtotal, const ProgressData::ReceiverFnc &receiver )
+// : _jobtotal(jobtotal)
+// , _receiver(receiver)
+// {
+//
+// }
+//
+// bool operator()( ProgressData::value_type progress )
+// {
+// return true;
+// }
+//
+// ProgressData::value_type _jobtotal;
+// ProgressData::ReceiverFnc _receiver;
+// };
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : RepoManagerOptions
@@ -59,8 +77,15 @@
}
/**
- * \short Simple callback to collect the results
- */
+ * \short Simple callback to collect the results
+ *
+ * Classes like RepoFileParser call the callback
+ * once per each repo in a file.
+ *
+ * Passing this functor as callback, you can collect
+ * all resuls at the end, without dealing with async
+ * code.
+ */
struct RepoCollector
{
RepoCollector()
@@ -246,7 +271,8 @@
////////////////////////////////////////////////////////////////////////////
- void RepoManager::refreshMetadata( const RepoInfo &info )
+ void RepoManager::refreshMetadata( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progress )
{
assert_alias(info);
assert_urls(info);
@@ -305,14 +331,16 @@
////////////////////////////////////////////////////////////////////////////
- void RepoManager::cleanMetadata( const RepoInfo &info )
+ void RepoManager::cleanMetadata( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progress )
{
filesystem::recursive_rmdir(rawcache_path_for_repoinfo(_pimpl->options, info));
}
////////////////////////////////////////////////////////////////////////////
- void RepoManager::buildCache( const RepoInfo &info )
+ void RepoManager::buildCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progress )
{
assert_alias(info);
Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info);
@@ -381,8 +409,12 @@
////////////////////////////////////////////////////////////////////////////
- void RepoManager::cleanCache( const RepoInfo &info )
+ void RepoManager::cleanCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv )
{
+ ProgressData progress;
+ progress.sendTo(progressrcv);
+
cache::CacheStore store(_pimpl->options.repoCachePath);
data::RecordId id = store.lookupRepository(info.alias());
@@ -398,7 +430,8 @@
return store.isCached(info.alias());
}
- Repository RepoManager::createFromCache( const RepoInfo &info )
+ Repository RepoManager::createFromCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progress )
{
cache::CacheStore store(_pimpl->options.repoCachePath);
@@ -417,9 +450,10 @@
////////////////////////////////////////////////////////////////////////////
- void RepoManager::addRepository( const RepoInfo &info )
+ void RepoManager::addRepository( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progress )
{
-
+
}
////////////////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/RepoManager.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.h?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.h (original)
+++ trunk/libzypp/zypp/RepoManager.h Sun Jun 17 18:05:12 2007
@@ -24,6 +24,7 @@
#include "zypp/RepoInfo.h"
#include "zypp/repo/RepoException.h"
#include "zypp/repo/RepoType.h"
+#include "zypp/ProgressData.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -91,7 +92,8 @@
* \throws repo::RepoUnknownTypeException if the metadata is unknown
* \throws Exception on unknown error.
*/
- void refreshMetadata( const RepoInfo &info );
+ void refreshMetadata( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short Clean local metadata
@@ -101,7 +103,8 @@
* \throws repo::RepoNoAliasException if can't figure an alias
* \throws Exception on unknown error.
*/
- void cleanMetadata( const RepoInfo &info );
+ void cleanMetadata( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short Refresh local cache
@@ -116,7 +119,8 @@
* \throws repo::RepoNoAliasException if can't figure an alias to look in cache
* \throws Exception on unknown error.
*/
- void buildCache( const RepoInfo &info );
+ void buildCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short clean local cache
@@ -128,7 +132,8 @@
* \throws repo::RepoNoAliasException if can't figure an alias to look in cache
* \throws Exception on unknown error.
*/
- void cleanCache( const RepoInfo &info );
+ void cleanCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short Whether a repository exists in cache
@@ -142,7 +147,8 @@
*
* \throw RepoNotCachedException When the source is not cached.
*/
- Repository createFromCache( const RepoInfo &info );
+ Repository createFromCache( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short Probe repo metadata type.
@@ -160,7 +166,8 @@
* \throws repo::RepoAlreadyExistsException If the repo clash some
* unique attribute like alias
*/
- void addRepository( const RepoInfo &info );
+ void addRepository( const RepoInfo &info,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* Adds a .repo file directly, which can contain
@@ -171,7 +178,8 @@
/**
* PROPOSAL
*/
- void removeRepository( const std::string & alias );
+ void removeRepository( const std::string & alias,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
public:
Modified: trunk/libzypp/zypp/cache/CacheStore.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/CacheStore.cc (original)
+++ trunk/libzypp/zypp/cache/CacheStore.cc Sun Jun 17 18:05:12 2007
@@ -751,7 +751,8 @@
return id;
}
-void CacheStore::cleanRepository( const data::RecordId &id )
+void CacheStore::cleanRepository( const data::RecordId &id,
+ const ProgressData::ReceiverFnc & progressrcv )
{
sqlite3_command cmd( _pimpl->con, "delete from repositories where id=:id");
cmd.bind(":id", id);
@@ -766,9 +767,10 @@
}
}
-void CacheStore::cleanRepository( const std::string &alias )
+void CacheStore::cleanRepository( const std::string &alias,
+ const ProgressData::ReceiverFnc & progressrcv )
{
- cleanRepository(lookupRepository(alias));
+ cleanRepository(lookupRepository(alias), progressrcv);
}
RepoStatus CacheStore::repositoryStatus( const data::RecordId &id )
Modified: trunk/libzypp/zypp/cache/CacheStore.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.h?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/cache/CacheStore.h (original)
+++ trunk/libzypp/zypp/cache/CacheStore.h Sun Jun 17 18:05:12 2007
@@ -27,6 +27,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/RepoStatus.h"
+#include "zypp/ProgressData.h"
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -356,7 +357,8 @@
* \param prpm The patch RPM object to insert.
* \return Record ID of the newly inserted record.
*/
- data::RecordId appendPatchRpm( const data::RecordId &repo_id, const data::PatchRpm_Ptr & prpm);
+ data::RecordId appendPatchRpm( const data::RecordId &repo_id,
+ const data::PatchRpm_Ptr & prpm);
/**
@@ -365,7 +367,8 @@
* \param drpm The delta RPM object to insert.
* \return Record ID of the newly inserted record.
*/
- data::RecordId appendDeltaRpm( const data::RecordId &repo_id, const data::DeltaRpm_Ptr & drpm);
+ data::RecordId appendDeltaRpm( const data::RecordId &repo_id,
+ const data::DeltaRpm_Ptr & drpm);
/**
@@ -540,7 +543,8 @@
* \throws CacheRecordNotFoundException if the repository
* id does not refer to a valid repository.
*/
- void cleanRepository( const data::RecordId &id );
+ void cleanRepository( const data::RecordId &id,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* \short Clean repository from cache
@@ -552,7 +556,8 @@
* \throws CacheRecordNotFoundException if the repository
* alias does not refer to a valid repository.
*/
- void cleanRepository( const std::string &alias );
+ void cleanRepository( const std::string &alias,
+ const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
* get the status of a cached repository
Modified: trunk/libzypp/zypp/repo/susetags/Downloader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/susetags/Downloader.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/susetags/Downloader.cc (original)
+++ trunk/libzypp/zypp/repo/susetags/Downloader.cc Sun Jun 17 18:05:12 2007
@@ -6,6 +6,7 @@
#include "zypp/Fetcher.h"
#include "zypp/repo/susetags/Downloader.h"
+#include "zypp/base/UserRequestException.h"
using namespace std;
@@ -22,7 +23,8 @@
}
-void Downloader::download( const Pathname &dest_dir )
+void Downloader::download( const Pathname &dest_dir,
+ const ProgressData::ReceiverFnc & progress )
{
MediaSetAccess media(_url, _path);
Fetcher fetcher;
Modified: trunk/libzypp/zypp/repo/susetags/Downloader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/susetags/Downloader.h?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/susetags/Downloader.h (original)
+++ trunk/libzypp/zypp/repo/susetags/Downloader.h Sun Jun 17 18:05:12 2007
@@ -12,6 +12,7 @@
#include "zypp/Url.h"
#include "zypp/Pathname.h"
+#include "zypp/ProgressData.h"
namespace zypp
{
@@ -24,7 +25,8 @@
{
public:
Downloader( const Url &url, const Pathname &path );
- void download( const Pathname &dest_dir );
+ void download( const Pathname &dest_dir,
+ const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
private:
Url _url;
Pathname _path;
Modified: trunk/libzypp/zypp/repo/yum/Downloader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/yum/Downloader.cc?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/yum/Downloader.cc (original)
+++ trunk/libzypp/zypp/repo/yum/Downloader.cc Sun Jun 17 18:05:12 2007
@@ -17,6 +17,7 @@
#include "zypp/parser/yum/RepomdFileReader.h"
#include "zypp/parser/yum/PatchesFileReader.h"
#include "Downloader.h"
+#include "zypp/base/UserRequestException.h"
using namespace std;
using namespace zypp::xml;
@@ -68,13 +69,17 @@
return true;
}
-void Downloader::download( const Pathname &dest_dir )
+void Downloader::download( const Pathname &dest_dir,
+ const ProgressData::ReceiverFnc & progressrcv )
{
Pathname repomdpath = "/repodata/repomd.xml";
Pathname keypath = "/repodata/repomd.xml.key";
Pathname sigpath = "/repodata/repomd.xml.asc";
-
+ ProgressData progress;
+ progress.sendTo(progressrcv);
+ progress.toMin();
+
_dest_dir = dest_dir;
if ( _media.doesFileExist(keypath) )
_fetcher.enqueue( OnMediaLocation().filename(keypath) );
@@ -84,6 +89,9 @@
_fetcher.start( dest_dir, _media );
+ if ( ! progress.tick() )
+ ZYPP_THROW(AbortRequestException());
+
SignatureFileChecker sigchecker;
if ( PathInfo( dest_dir + sigpath ).isExist() )
@@ -95,7 +103,9 @@
_fetcher.enqueue( OnMediaLocation().filename(repomdpath), sigchecker );
_fetcher.start( dest_dir, _media);
-
+ if ( ! progress.tick() )
+ ZYPP_THROW(AbortRequestException());
+
_fetcher.reset();
Reader reader( dest_dir + "/repodata/repomd.xml" );
@@ -103,6 +113,7 @@
// ready, go!
_fetcher.start( dest_dir, _media);
+ progress.toMax();
}
}// ns yum
Modified: trunk/libzypp/zypp/repo/yum/Downloader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/yum/Downloader.h?rev=5761&r1=5760&r2=5761&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/yum/Downloader.h (original)
+++ trunk/libzypp/zypp/repo/yum/Downloader.h Sun Jun 17 18:05:12 2007
@@ -17,6 +17,7 @@
#include "zypp/MediaSetAccess.h"
#include "zypp/parser/xml/Reader.h"
#include "zypp/repo/yum/ResourceType.h"
+#include "zypp/ProgressData.h"
namespace zypp
{
@@ -44,7 +45,8 @@
/**
* starts the download to local directory \a dest_dir
*/
- void download( const Pathname &dest_dir );
+ void download( const Pathname &dest_dir,
+ const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
protected:
bool repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org