From 2b56aa31724ffc7ac01f3f919b6cbc2f0aa396ef Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 27 Jul 2007 15:35:30 +0000 Subject: [PATCH] - invert arguments in sqlite3x setprogresshandler - add some docu - try to make clean cache also tick --- zypp/RepoManager.cc | 6 ++++-- zypp/cache/CacheStore.cc | 3 +++ zypp/cache/sqlite3x/sqlite3x.hpp | 13 +++++++++++-- zypp/cache/sqlite3x/sqlite3x_connection.cpp | 9 +++++++-- zypp/repo/cached/RepoImpl.cc | 8 ++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index 1df57f3..85c05b7 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -604,11 +604,13 @@ namespace zypp callback::SendReport report; progress.sendTo( ProgressReportAdaptor( progressrcv, report ) ); progress.name(str::form(_("Cleaning repository '%s' cache"), info.alias().c_str())); - progress.toMin(); - + cache::CacheStore store(_pimpl->options.repoCachePath); data::RecordId id = store.lookupRepository(info.alias()); + + CombinedProgressData subprogrcv(progress); + store.cleanRepository(id); store.commit(); } diff --git a/zypp/cache/CacheStore.cc b/zypp/cache/CacheStore.cc index e4da305..4e62af9 100644 --- a/zypp/cache/CacheStore.cc +++ b/zypp/cache/CacheStore.cc @@ -767,6 +767,7 @@ void CacheStore::cleanRepository( const data::RecordId &id, const ProgressData::ReceiverFnc & progressrcv ) { sqlite3_command cmd( _pimpl->con, "delete from repositories where id=:id"); + _pimpl->con.setprogresshandler(progressrcv); cmd.bind(":id", id); try @@ -775,8 +776,10 @@ void CacheStore::cleanRepository( const data::RecordId &id, } catch ( const sqlite3x::database_error &e ) { + _pimpl->con.resetprogresshandler(); ZYPP_THROW(CacheRecordNotFoundException()); } + _pimpl->con.resetprogresshandler(); } void CacheStore::cleanRepository( const std::string &alias, diff --git a/zypp/cache/sqlite3x/sqlite3x.hpp b/zypp/cache/sqlite3x/sqlite3x.hpp index 0ff2b0d..0a11ce3 100644 --- a/zypp/cache/sqlite3x/sqlite3x.hpp +++ b/zypp/cache/sqlite3x/sqlite3x.hpp @@ -47,8 +47,17 @@ public: sqlite3_connection(const char *db); sqlite3_connection(const wchar_t *db); - void setprogresshandler( int, - const zypp::ProgressData::ReceiverFnc & ); + /** + * \short Sets a tick progress callback + * \param fnc callback + * \param n number of sqlite vm opcodes per tick + */ + void setprogresshandler( const zypp::ProgressData::ReceiverFnc &fnc, + int n = 100 ); + /** + * \short Disables tick progress callback + */ + void resetprogresshandler(); ~sqlite3_connection(); diff --git a/zypp/cache/sqlite3x/sqlite3x_connection.cpp b/zypp/cache/sqlite3x/sqlite3x_connection.cpp index b5af44e..e3ad870 100644 --- a/zypp/cache/sqlite3x/sqlite3x_connection.cpp +++ b/zypp/cache/sqlite3x/sqlite3x_connection.cpp @@ -73,8 +73,8 @@ sqlite3_connection::~sqlite3_connection() if (this->db) sqlite3_close(this->db); } -void sqlite3_connection::setprogresshandler( int n, - const zypp::ProgressData::ReceiverFnc &fnc ) +void sqlite3_connection::setprogresshandler( const zypp::ProgressData::ReceiverFnc &fnc, + int n) { _ticks.sendTo(fnc); if ( fnc ) @@ -83,6 +83,11 @@ void sqlite3_connection::setprogresshandler( int n, sqlite3_progress_handler(db, n, NULL, (void*)this); } +void sqlite3_connection::resetprogresshandler() +{ + sqlite3_progress_handler(db, 0, NULL, (void*)this); +} + void sqlite3_connection::open(const char *db) { if (sqlite3_open(db, &this->db)!=SQLITE_OK) diff --git a/zypp/repo/cached/RepoImpl.cc b/zypp/repo/cached/RepoImpl.cc index 2634512..236e543 100644 --- a/zypp/repo/cached/RepoImpl.cc +++ b/zypp/repo/cached/RepoImpl.cc @@ -83,7 +83,7 @@ void RepoImpl::createResolvables() try { sqlite3_connection con((_options.dbdir + "zypp.db").asString().c_str()); - con.setprogresshandler(100, subprogrcv); + con.setprogresshandler(subprogrcv, 100); con.executenonquery("PRAGMA cache_size=8000;"); con.executenonquery("BEGIN;"); @@ -171,7 +171,7 @@ void RepoImpl::createResolvables() } } con.executenonquery("COMMIT;"); - con.setprogresshandler(00, ProgressData::ReceiverFnc()); + con.resetprogresshandler(); } catch(exception &ex) { cerr << "Exception Occured: " << ex.what() << endl; @@ -201,7 +201,7 @@ void RepoImpl::createPatchAndDeltas() try { sqlite3_connection con((_options.dbdir + "zypp.db").asString().c_str()); - //con.setprogresshandler(500, global_progress_handler, (void*)this); + con.setprogresshandler(subprogrcv); con.executenonquery("PRAGMA cache_size=8000;"); con.executenonquery("BEGIN;"); @@ -300,7 +300,7 @@ void RepoImpl::createPatchAndDeltas() _patchRpms.push_back(patch); } - con.setprogresshandler(0, ProgressData::ReceiverFnc()); + con.resetprogresshandler(); } catch(exception &ex) { cerr << "Exception Occured: " << ex.what() << endl; -- 2.7.4