|
|
|
@@ -145,9 +145,9 @@ def plugins(): |
|
|
|
def download_addon(name): |
|
|
|
|
|
|
|
plugin = cbpi.cache["plugins"].get(name) |
|
|
|
plugin["loading"] = True |
|
|
|
if plugin is None: |
|
|
|
return ('', 404) |
|
|
|
plugin["loading"] = True |
|
|
|
try: |
|
|
|
Repo.clone_from(plugin.get("repo_url"), "./modules/plugins/%s/" % (name)) |
|
|
|
cbpi.notify("Download successful", "Plugin %s downloaded successfully" % name) |
|
|
|
@@ -158,9 +158,28 @@ def download_addon(name): |
|
|
|
|
|
|
|
@blueprint.route('/<name>/update', methods=['POST']) |
|
|
|
def update_addon(name): |
|
|
|
""" |
|
|
|
Updates a addon |
|
|
|
|
|
|
|
:param name: plugin name |
|
|
|
:return: HTTP 204 if ok - HTTP 500 if plugin not exists |
|
|
|
""" |
|
|
|
plugin = cbpi.cache["plugins"].get(name) |
|
|
|
if plugin is None: |
|
|
|
return ('', 404) |
|
|
|
plugin["loading"] = True |
|
|
|
|
|
|
|
repo = Repo("./modules/plugins/%s/" % (name)) |
|
|
|
o = repo.remotes.origin |
|
|
|
info = o.pull() |
|
|
|
if repo.remotes.origin.url == plugin.get('repo_url'): |
|
|
|
o = repo.remotes.origin |
|
|
|
_info = o.pull() |
|
|
|
else: |
|
|
|
# url has changed the plugin needs to be re-downloaded |
|
|
|
deletePlugin(name) |
|
|
|
return download_addon(name) |
|
|
|
|
|
|
|
reload(name) |
|
|
|
plugin["loading"] = False |
|
|
|
cbpi.notify("Plugin Updated", "Plugin %s updated successfully. Please restart the system" % name) |
|
|
|
return ('', 204) |
|
|
|
|
|
|
|
|