Skip to content

Commit

Permalink
fixed repeated service save problem (bnc#873683#c7)
Browse files Browse the repository at this point in the history
- 3.1.8
  • Loading branch information
lslezak committed Apr 15, 2014
1 parent a23afaa commit f714260
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings-devel-doc.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-pkg-bindings-devel-doc
Version: 3.1.7
Version: 3.1.8
Release: 0
License: GPL-2.0
Group: Documentation/HTML
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-pkg-bindings.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Apr 15 14:48:45 UTC 2014 - lslezak@suse.cz

- fixed repeated service save problem (bnc#873683#c7)
- 3.1.8

-------------------------------------------------------------------
Wed Apr 2 15:11:58 UTC 2014 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-pkg-bindings
Version: 3.1.7
Version: 3.1.8
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
4 changes: 4 additions & 0 deletions src/PkgService.cc
Expand Up @@ -54,3 +54,7 @@ std::string PkgService::origAlias() const
return _old_alias;
}

void PkgService::setOrigAlias(const std::string& orig_alias)
{
_old_alias = orig_alias;
}
1 change: 1 addition & 0 deletions src/PkgService.h
Expand Up @@ -40,6 +40,7 @@ class PkgService : public zypp::ServiceInfo

std::string origAlias() const;

void setOrigAlias(const std::string& orig_alias);

private:

Expand Down
10 changes: 6 additions & 4 deletions src/ServiceManager.cc
Expand Up @@ -53,7 +53,7 @@ void ServiceManager::LoadServices(const zypp::RepoManager &repomgr)
}
}

void ServiceManager::SaveServices(zypp::RepoManager &repomgr) const
void ServiceManager::SaveServices(zypp::RepoManager &repomgr)
{
for_ (it, _known_services.begin(), _known_services.end())
{
Expand All @@ -75,9 +75,9 @@ void ServiceManager::SaveServices(zypp::RepoManager &repomgr) const
}
}

bool ServiceManager::SaveService(const std::string &alias, zypp::RepoManager &repomgr) const
bool ServiceManager::SaveService(const std::string &alias, zypp::RepoManager &repomgr)
{
PkgServices::const_iterator serv_it = _known_services.find(alias);
PkgServices::iterator serv_it = _known_services.find(alias);

if (serv_it == _known_services.end())
{
Expand Down Expand Up @@ -287,7 +287,7 @@ ServiceManager::Services::size_type ServiceManager::size() const
return _known_services.size();
}

void ServiceManager::SavePkgService(const PkgService &s_known, zypp::RepoManager &repomgr) const
void ServiceManager::SavePkgService(PkgService &s_known, zypp::RepoManager &repomgr) const
{
const std::string alias(s_known.alias());
const zypp::ServiceInfo s_stored = repomgr.getService(alias);
Expand All @@ -305,6 +305,8 @@ void ServiceManager::SavePkgService(const PkgService &s_known, zypp::RepoManager
y2milestone("Adding new service %s", alias.c_str());
// add the service
repomgr.addService(s_known);
// set the old alias to properly save it next time
s_known.setOrigAlias(alias);
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions src/ServiceManager.h
Expand Up @@ -42,9 +42,9 @@ class ServiceManager

void LoadServices(const zypp::RepoManager &repomgr);

void SaveServices(zypp::RepoManager &repomgr) const;
void SaveServices(zypp::RepoManager &repomgr);

bool SaveService(const std::string &alias, zypp::RepoManager &repomgr) const;
bool SaveService(const std::string &alias, zypp::RepoManager &repomgr);

bool AddService(const std::string &alias, const std::string &url);

Expand All @@ -70,7 +70,7 @@ class ServiceManager
private:

// internal helper method
void SavePkgService(const PkgService &s_known, zypp::RepoManager &repomgr) const;
void SavePkgService(PkgService &s_known, zypp::RepoManager &repomgr) const;

// current alias -> PkgService for convenient search by alias
typedef std::map<std::string, PkgService> PkgServices;
Expand Down

0 comments on commit f714260

Please sign in to comment.