commit ce46c6e8266054d199fc9ff7d31870800202b628
parent f9922c2a6a4178a28e319d459ab93941a1735c99
Author: cfillion <cfillion@users.noreply.github.com>
Date: Wed, 6 Sep 2017 15:41:52 -0400
api: refactor AddSetRepository
Diffstat:
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/api_repo.cpp b/src/api_repo.cpp
@@ -49,20 +49,16 @@ autoInstall: usually set to 2 (obey user setting).)",
try {
const Remote &existing = g_reapack->remote(name);
- if(!url || strlen(url) == 0)
- url = existing.url().c_str();
+ Remote remote(existing);
+ remote.setName(name);
+ remote.setUrl(url && strlen(url) > 0 ? url : existing.url());
+ remote.setAutoInstall(boost::lexical_cast<tribool>(autoInstall));
- if(existing.isProtected() && url != existing.url()) {
+ if(existing.isProtected() && remote.url() != existing.url()) {
if(errorOut)
- snprintf(errorOut, errorOut_sz, "cannot change URL of a protected repository");
+ snprintf(errorOut, errorOut_sz, "cannot change the URL of a protected repository");
return false;
}
-
- Remote remote = g_reapack->remote(name);
- remote.setName(name);
- remote.setUrl(url);
- remote.setAutoInstall(boost::lexical_cast<tribool>(autoInstall));
-
if(!g_reapack->addSetRemote(remote, enable))
return false;
}