{
Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
RepoType repokind = info.type();
+ RepoStatus status;
switch ( repokind.toEnum() )
{
case RepoType::NONE_e:
{
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);
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();
}
// update timestamp and checksum
- //store.updateRepository(id, )
+ store.updateRepositoryStatus(id, raw_metadata_status);
MIL << "Commit cache.." << endl;
store.commit();
+ progress.toMax();
}
////////////////////////////////////////////////////////////////////////////
/** Dtor */
~RepoManager();
- enum RepoRefreshPolicy
+ enum RawMetadataRefreshPolicy
{
RefreshIfNeeded,
RefreshForced
* \throws Exception on unknown error.
*/
void refreshMetadata( const RepoInfo &info,
- RepoRefreshPolicy policy = RefreshIfNeeded,
+ RawMetadataRefreshPolicy policy = RefreshIfNeeded,
const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
/**
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);" ));
*/
sqlite3_connection con;
- sqlite3_command_ptr update_repository_cmd;
sqlite3_command_ptr insert_resolvable_in_repository_cmd;
sqlite3_command_ptr select_name_cmd;
return id;
}
-void CacheStore::updateRepository( const RecordId &id,
- const string &checksum,
- const Date ×tamp )
+void CacheStore::updateRepositoryStatus( const RecordId &id,
+ const RepoStatus &status )
{
- _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();
+ 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 )
{
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);
}
}
*
* 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