From 161f9bb04e1af56e4b3fa1d172890cbc6b9d63e7 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Fri, 16 May 2008 14:45:10 +0000 Subject: [PATCH] don't run merge in save when toAdd/Remove queue is empty throw when locks cannot load its file --- zypp/Locks.cc | 11 ++++++++--- zypp/PoolQueryUtil.tcc | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/zypp/Locks.cc b/zypp/Locks.cc index 84d647e..af0ea49 100644 --- a/zypp/Locks.cc +++ b/zypp/Locks.cc @@ -432,11 +432,16 @@ void Locks::save( const Pathname& file ) callback::SendReport report; report->start(); - if (!_pimpl->mergeList(report)) + + if ((_pimpl->toAdd.size() | _pimpl->toRemove.size())!=0) { - report->finish(SavingLocksReport::ABORTED); - return; + if (!_pimpl->mergeList(report)) + { + report->finish(SavingLocksReport::ABORTED); + return; + } } + DBG << "writed "<< _pimpl->locks.size() << "locks" << endl; writePoolQueriesToFile( file, _pimpl->locks.begin(), _pimpl->locks.end() ); report->finish(SavingLocksReport::NO_ERROR); diff --git a/zypp/PoolQueryUtil.tcc b/zypp/PoolQueryUtil.tcc index 487971f..4a0ec40 100644 --- a/zypp/PoolQueryUtil.tcc +++ b/zypp/PoolQueryUtil.tcc @@ -18,6 +18,7 @@ #include "zypp/Pathname.h" #include "zypp/PoolQuery.h" +#include "zypp/base/String.h" namespace zypp { @@ -39,7 +40,7 @@ namespace zypp std::ifstream fin( file.c_str() ); if (!fin) - return; //TODO exception + ZYPP_THROW(Exception(str::form("Cannot open file %s",file.c_str()))); do { @@ -63,7 +64,7 @@ namespace zypp std::ofstream fout( file.c_str(), std::ios_base::out | std::ios_base::trunc ); if (!fout) - return; //TODO exception + ZYPP_THROW(Exception(str::form("Cannot open file %s",file.c_str()))); for_( it, begin, end ) { -- 2.7.4