Skip to content

Commit

Permalink
added new call ServiceForceRefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Apr 6, 2016
1 parent aeea6ca commit be9052e
Show file tree
Hide file tree
Showing 7 changed files with 48 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.31
Version: 3.1.31.1
Release: 0
License: GPL-2.0
Group: Documentation/HTML
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-pkg-bindings.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Apr 6 15:51:40 CEST 2016 - schubi@suse.de

- Added new call: ServiceForceRefresh
(bnc#967828)
- 3.1.31.1

-------------------------------------------------------------------
Thu Oct 8 21:07:44 UTC 2015 - igonzalezsosa@suse.com

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.31
Version: 3.1.31.1
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
3 changes: 3 additions & 0 deletions src/PkgFunctions.h
Expand Up @@ -130,6 +130,7 @@ class PkgFunctions
int last_reported_mediumnr;

YCPValue SourceRefreshHelper(const YCPInteger &id, bool forced = false);
YCPValue ServiceRefreshHelper(const YCPString &alias, bool forced = false);

// helper for updating repository manager after changing the target root
// return true if the target root has been changed
Expand Down Expand Up @@ -791,6 +792,8 @@ class PkgFunctions
/* TYPEINFO: boolean(string)*/
YCPValue ServiceRefresh(const YCPString&);
/* TYPEINFO: string(string)*/
YCPValue ServiceForceRefresh(const YCPString&);
/* TYPEINFO: string(string)*/
YCPValue ServiceURL(const YCPString &alias);
/* TYPEINFO: string(string)*/
YCPValue ServiceProbe(const YCPString &url);
Expand Down
30 changes: 26 additions & 4 deletions src/Service.cc
Expand Up @@ -359,12 +359,12 @@ YCPValue PkgFunctions::ServiceSet(const YCPString &old_alias, const YCPMap &serv
}

/**
@builtin ServiceRefresh
@short Refresh the service, the service must already be saved on the system!
@builtin ServiceRefreshHelper
@short Helper call for refreshing services
@param alias alias of the service to refresh
@return boolean false if failed
*/
YCPValue PkgFunctions::ServiceRefresh(const YCPString &alias)
YCPValue PkgFunctions::ServiceRefreshHelper(const YCPString &alias, bool force)
{
try
{
Expand All @@ -378,7 +378,7 @@ YCPValue PkgFunctions::ServiceRefresh(const YCPString &alias)

zypp::RepoManager* repomanager = CreateRepoManager();

if (!service_manager.RefreshService(alias_str, *repomanager))
if (!service_manager.RefreshService(alias_str, *repomanager, force))
{
return YCPBoolean(false);
}
Expand Down Expand Up @@ -448,6 +448,28 @@ YCPValue PkgFunctions::ServiceRefresh(const YCPString &alias)
return YCPBoolean(false);
}

/**
@builtin ServiceRefresh
@short Refresh the service, the service must already be saved on the system!
@param alias alias of the service to refresh
@return boolean false if failed
*/
YCPValue PkgFunctions::ServiceRefresh(const YCPString &alias)
{
return ServiceRefreshHelper(alias, false);
}

/**
@builtin ServiceForceRefresh
@short Service forced refresh, the service must already be saved on the system!
@param alias alias of the service to refresh
@return boolean false if failed
*/
YCPValue PkgFunctions::ServiceForceRefresh(const YCPString &alias)
{
return ServiceRefreshHelper(alias, true);
}

/**
@builtin ServiceProbe
@short Probe service type at a URL
Expand Down
11 changes: 9 additions & 2 deletions src/ServiceManager.cc
Expand Up @@ -107,7 +107,7 @@ bool ServiceManager::SaveService(const std::string &alias, zypp::RepoManager &re
return true;
}

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

Expand All @@ -117,7 +117,14 @@ bool ServiceManager::RefreshService(const std::string &alias, zypp::RepoManager
return false;
}

repomgr.refreshService(serv_it->second);
if (force)
{
repomgr.refreshService(serv_it->second, zypp::RepoManager::RefreshService_forceRefresh);
}
else
{
repomgr.refreshService(serv_it->second);
}

// load the service from disk
PkgService new_service(repomgr.getService(alias), alias);
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceManager.h
Expand Up @@ -54,7 +54,7 @@ class ServiceManager

bool SetService(const std::string &old_alias, const zypp::ServiceInfo &srv);

bool RefreshService(const std::string &alias, zypp::RepoManager &repomgr);
bool RefreshService(const std::string &alias, zypp::RepoManager &repomgr, bool force = false);

std::string Probe(const zypp::Url &url, const zypp::RepoManager &repomgr) const;

Expand Down

0 comments on commit be9052e

Please sign in to comment.