[zypp-commit] r5780 - in /trunk/libzypp/zypp: RepoManager.cc RepoManager.h cache/CacheStore.cc cache/CacheStore.h
Author: dmacvicar Date: Tue Jun 19 01:00:40 2007 New Revision: 5780 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5780&view=rev Log: - smart refresh works both for metadata and cache. Modified: trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/RepoManager.h trunk/libzypp/zypp/cache/CacheStore.cc trunk/libzypp/zypp/cache/CacheStore.h Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=5780&r1=5779&r2=5780&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Tue Jun 19 01:00:40 2007 @@ -257,6 +257,7 @@ { Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info ); RepoType repokind = info.type(); + RepoStatus status; switch ( repokind.toEnum() ) { case RepoType::NONE_e: @@ -271,27 +272,23 @@ { case RepoType::RPMMD_e : { - return RepoStatus( rawpath + "/repodata/repomd.xml"); + status = RepoStatus( rawpath + "/repodata/repomd.xml"); } break; case RepoType::YAST2_e : { - return RepoStatus( rawpath + "/content"); + status = RepoStatus( rawpath + "/content"); } break; default: ZYPP_THROW(RepoUnknownTypeException()); } - } - - RepoStatus RepoManager::cacheStatus( const RepoInfo &info ) - { - return RepoStatus(); + return status; } void RepoManager::refreshMetadata( const RepoInfo &info, - RepoRefreshPolicy policy, + RawMetadataRefreshPolicy policy, const ProgressData::ReceiverFnc & progress ) { assert_alias(info); @@ -405,22 +402,38 @@ void RepoManager::buildCache( const RepoInfo &info, CacheBuildPolicy policy, - const ProgressData::ReceiverFnc & progress ) + const ProgressData::ReceiverFnc & progressrcv ) { + ProgressData progress; + progress.sendTo(progressrcv); + progress.toMin(); assert_alias(info); Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info); cache::CacheStore store(_pimpl->options.repoCachePath); + RepoStatus raw_metadata_status = rawMetadataStatus(info); if ( store.isCached( info.alias() ) ) { - MIL << info.alias() << " is already cached, cleaning..." << endl; + MIL << info.alias() << " is already cached." << endl; data::RecordId id = store.lookupRepository(info.alias()); + RepoStatus cache_status = store.repositoryStatus(id); + + if ( cache_status.checksum() == raw_metadata_status.checksum() ) + { + MIL << info.alias() << " cache is up to date with metadata." << endl; + if ( policy == BuildIfNeeded ) { + progress.toMax(); + return; + } + else { + MIL << "Build cache is forced" << endl; + } + } store.cleanRepository(id); } data::RecordId id = store.lookupOrAppendRepository(info.alias()); - // do we have type? repo::RepoType repokind = info.type(); @@ -456,10 +469,11 @@ } // update timestamp and checksum - //store.updateRepository(id, ) + store.updateRepositoryStatus(id, raw_metadata_status); MIL << "Commit cache.." << endl; store.commit(); + progress.toMax(); } //////////////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/RepoManager.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.h?rev=5780&r1=5779&r2=5780&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.h (original) +++ trunk/libzypp/zypp/RepoManager.h Tue Jun 19 01:00:40 2007 @@ -74,7 +74,7 @@ /** Dtor */ ~RepoManager(); - enum RepoRefreshPolicy + enum RawMetadataRefreshPolicy { RefreshIfNeeded, RefreshForced @@ -114,7 +114,7 @@ * \throws Exception on unknown error. */ void refreshMetadata( const RepoInfo &info, - RepoRefreshPolicy policy = RefreshIfNeeded, + RawMetadataRefreshPolicy policy = RefreshIfNeeded, const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() ); /** Modified: trunk/libzypp/zypp/cache/CacheStore.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.cc?rev=5780&r1=5779&r2=5780&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/CacheStore.cc (original) +++ trunk/libzypp/zypp/cache/CacheStore.cc Tue Jun 19 01:00:40 2007 @@ -57,8 +57,6 @@ insert_resolvable_in_repository_cmd.reset( new sqlite3_command( con, "insert into resolvables_repositories (resolvable_id, repository_id) values (:resolvable_id, :repository_id);" )); - update_repository_cmd.reset( new sqlite3_command( con, "update repositories set checksum=:checksum, timestamp=:timestamp where id=:repository_id;" )); - select_repository_cmd.reset( new sqlite3_command( con, "select id from repositories where alias=:alias;" )); insert_repository_cmd.reset( new sqlite3_command( con, "insert into repositories (alias,timestamp) values (:alias, :timestamp);" )); @@ -131,7 +129,6 @@ */ sqlite3_connection con; - sqlite3_command_ptr update_repository_cmd; sqlite3_command_ptr insert_resolvable_in_repository_cmd; sqlite3_command_ptr select_name_cmd; @@ -718,14 +715,21 @@ return id; } -void CacheStore::updateRepository( const RecordId &id, - const string &checksum, - const Date ×tamp ) -{ - _pimpl->update_repository_cmd->bind(":repository_id", id); - _pimpl->update_repository_cmd->bind(":checksum", checksum); - _pimpl->update_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) timestamp) ); - _pimpl->insert_repository_cmd->executenonquery(); +void CacheStore::updateRepositoryStatus( const RecordId &id, + const RepoStatus &status ) +{ + sqlite3_command cmd( _pimpl->con, "update repositories set checksum=:checksum, timestamp=:timestamp where id=:repository_id;"); + cmd.bind(":repository_id", id); + cmd.bind(":checksum", status.checksum()); + cmd.bind(":timestamp", static_cast<int>((Date::ValueType) status.timestamp()) ); + try + { + cmd.executenonquery(); + } + catch ( const sqlite3x::database_error &e ) + { + ZYPP_RETHROW(e); + } } RecordId CacheStore::lookupOrAppendRepository( const string &alias ) @@ -788,12 +792,14 @@ { status.setChecksum( reader.getstring(2) ); status.setTimestamp( reader.getstring(3) ); + return status; } - return status; + else + ZYPP_THROW(CacheRecordNotFoundException()); } catch ( const sqlite3x::database_error &e ) { - ZYPP_THROW(CacheRecordNotFoundException()); + ZYPP_RETHROW(e); } } Modified: trunk/libzypp/zypp/cache/CacheStore.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/cache/CacheStore.h?rev=5780&r1=5779&r2=5780&view=diff ============================================================================== --- trunk/libzypp/zypp/cache/CacheStore.h (original) +++ trunk/libzypp/zypp/cache/CacheStore.h Tue Jun 19 01:00:40 2007 @@ -529,9 +529,8 @@ * * If the repository does not exists, nothing will happen */ - void updateRepository( const data::RecordId &id, - const std::string &checksum, - const Date ×tamp = Date::now() ); + void updateRepositoryStatus( const data::RecordId &id, + const RepoStatus &status ); /** * \short Clean repository from cache -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
dmacvicar@svn.opensuse.org