updater: reintrodotte funzioni per creare/rimuovere/rinominare

This commit is contained in:
marco
2020-09-22 20:44:21 +02:00
parent d489fb443b
commit cd1c73834c
2 changed files with 13 additions and 6 deletions

View File

@@ -485,9 +485,6 @@ def get_server_parameters(server):
# Debriders
elif filetools.isfile(filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json")):
path = filetools.join(config.get_runtime_path(), "servers", "debriders", server + ".json")
else:
from core.support import dbg
dbg()
# When the server is not well defined in the channel (there is no connector), it shows an error because there is no "path" and the channel has to be checked
dict_server = jsontools.load(filetools.read(path))

View File

@@ -117,9 +117,9 @@ def check(background=False):
poFilesChanged = True
if 'service.py' in file["filename"]:
serviceChanged = True
if (file['status'] == 'modified' or file['status'] == 'added') and 'patch' not in file:
# è un file NON testuale, lo devo scaricare
# se non è già applicato
if (file['status'] == 'modified' and 'patch' not in file) or file['status'] == 'added':
# è un file NON testuale che è stato modificato, oppure è un file nuovo (la libreria non supporta la creazione di un nuovo file)
# lo devo scaricare
filename = os.path.join(addonDir, file['filename'])
dirname = os.path.dirname(filename)
if not (filetools.isfile(os.path.join(addonDir, file['filename'])) and getSha(filename) == file['sha']):
@@ -127,6 +127,16 @@ def check(background=False):
if not os.path.exists(dirname):
os.makedirs(dirname)
urllib.urlretrieve(file['raw_url'], filename)
elif file['status'] == 'removed':
remove(os.path.join(addonDir, file["filename"]))
elif file['status'] == 'renamed':
# se non è già applicato
if not (filetools.isfile(os.path.join(addonDir, file['filename'])) and getSha(os.path.join(addonDir, file['filename'])) == file['sha']):
dirs = file['filename'].split('/')
for d in dirs[:-1]:
if not filetools.isdir(os.path.join(addonDir, d)):
filetools.mkdir(os.path.join(addonDir, d))
filetools.move(os.path.join(addonDir, file['previous_filename']), os.path.join(addonDir, file['filename']))
changelog += commitJson['commit']['message'] + "\n"
except:
import traceback