[AB-xxx] fixing deployment of zip artifacts named the same name being deployed twice

This commit is contained in:
Sheldan
2021-04-05 01:11:45 +02:00
parent ecc81884e6
commit df1a0cfc02
2 changed files with 11 additions and 7 deletions

View File

@@ -59,15 +59,18 @@ if not use_folder:
if deploy_templates: if deploy_templates:
print("Deploying templates.") print("Deploying templates.")
for template_artifact in artifact_config['template_artifacts']: for template_artifact in artifact_config['template_artifacts']:
folder_name = template_artifact + "-templates"
os.mkdir(folder_name)
with ZipFile('templates/' + template_artifact + '.zip', 'r') as template_zip: with ZipFile('templates/' + template_artifact + '.zip', 'r') as template_zip:
template_zip.extractall(template_artifact) template_zip.extractall(folder_name)
templates_deploy.deploy_template_folder(db_config, template_artifact) templates_deploy.deploy_template_folder(db_config, folder_name)
print("Deploying translation templates") print("Deploying translation templates")
for template_artifact in artifact_config['translation_artifacts']: for template_artifact in artifact_config['translation_artifacts']:
folder_name = template_artifact + "-translations"
with ZipFile('translations/' + template_artifact + '.zip', 'r') as template_zip: with ZipFile('translations/' + template_artifact + '.zip', 'r') as template_zip:
template_zip.extractall(template_artifact) template_zip.extractall(folder_name)
templates_deploy.deploy_template_folder(db_config, template_artifact) templates_deploy.deploy_template_folder(db_config, folder_name)
if use_folder: if use_folder:
print("Only deploying folder.") print("Only deploying folder.")

View File

@@ -23,7 +23,8 @@ def deploy_template_folder(db_config, folder):
print('Deploying %s templates from folder %s' % (len(templates), folder)) print('Deploying %s templates from folder %s' % (len(templates), folder))
with engine.connect() as con: with engine.connect() as con:
statement = text("""INSERT INTO template(key, content, last_modified) VALUES(:key, :content, NOW()) ON CONFLICT (key) DO UPDATE SET content = :content""") with con.begin():
statement = text("""INSERT INTO template(key, content, last_modified) VALUES(:key, :content, NOW()) ON CONFLICT (key) DO UPDATE SET content = :content""")
for line in templates: for line in templates:
con.execute(statement, **line) con.execute(statement, **line)