Support display when remote already exists.

master
Marko Semet 2020-04-16 16:08:46 +02:00
parent 00d79c8adf
commit dc8acb7543
2 changed files with 6 additions and 2 deletions

View File

@ -27,5 +27,9 @@ def remote_add_gen(name:str, rtype:str, info):
async def remote_add(con:utils.Connection):
result = await con.call({"operation": "remote-add", "name": name, "type": rtype, "info": info})
if result["status"] != "success":
raise RuntimeError("Wasn't able to add remote.") # TODO: Show error
if result["status"] == "fail-already-exists":
print("Remote %s already exists." % name)
exit(1)
else:
raise RuntimeError("Wasn't able to add remote.") # TODO: Show error
return remote_add

View File

@ -63,7 +63,7 @@ async def add_remote(data:dict):
async with config.config_lock:
# Check
if name in config.remotes:
raise ValueError("'%s' remote already exists." % name)
return {"status": "fail-already-exists"}
# Set remote
config.remotes[name] = rem