Parcourir la source

change update_addon to delete/download if the repo_url was changed

pull/258/head
Juan Pablo Giménez il y a 5 ans
Parent
révision
0a1b8245a6
1 fichiers modifiés avec 22 ajouts et 3 suppressions
  1. +22
    -3
      modules/addon/endpoints.py

+ 22
- 3
modules/addon/endpoints.py Voir le fichier

@@ -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)



Chargement…
Annuler
Enregistrer