Skip to content
Snippets Groups Projects
Verified Commit 8241e608 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

FIX: missing uploads due to unchanged checksum

parent ca0a197e
No related branches found
No related tags found
No related merge requests found
...@@ -104,5 +104,5 @@ style: ...@@ -104,5 +104,5 @@ style:
stage: style stage: style
image: $CI_REGISTRY_IMAGE image: $CI_REGISTRY_IMAGE
script: script:
- autopep8 -r --diff --exit-code . - autopep8 -ar --diff --exit-code .
allow_failure: true allow_failure: true
...@@ -110,7 +110,7 @@ def main(rec_id): ...@@ -110,7 +110,7 @@ def main(rec_id):
try: try:
el.download(target) el.download(target)
print("Downloaded:", target) print("Downloaded:", target)
except: except BaseException:
print("Failed download of:", target) print("Failed download of:", target)
for ent in cont: for ent in cont:
...@@ -128,6 +128,7 @@ def defineParser(): ...@@ -128,6 +128,7 @@ def defineParser():
'-i', '-i',
'--id', '--id',
type=int, type=int,
required=True,
help='the id of the record that shall be copied and then changed') help='the id of the record that shall be copied and then changed')
return parser return parser
......
...@@ -58,6 +58,7 @@ def main(filename, rerun=False): ...@@ -58,6 +58,7 @@ def main(filename, rerun=False):
for el in cont: for el in cont:
if isinstance(el, db.File): if isinstance(el, db.File):
el._checksum = None
target = os.path.join("downloads", el.path[1:]) target = os.path.join("downloads", el.path[1:])
if os.path.exists(target): if os.path.exists(target):
...@@ -69,32 +70,11 @@ def main(filename, rerun=False): ...@@ -69,32 +70,11 @@ def main(filename, rerun=False):
if (isinstance(el, db.Property) or isinstance(el, db.RecordType)): if (isinstance(el, db.Property) or isinstance(el, db.RecordType)):
model.append(el) model.append(el)
# create new file objects and replace the existing one
# TODO why is this necessary?
new_files = []
print(files)
if not rerun:
for fi in files:
new = db.File(file=fi.file, path=fi.path, name=fi.name, id=fi.id,
description=fi.description)
for p in fi.parents:
new.add_parent(p)
new_files.append(new)
else:
for fi in files:
new = db.File(path=fi.path, id=fi.id)
new_files.append(new)
# remove entities of the model from the container # remove entities of the model from the container
for el in model+files: for el in model+files:
cont.remove(el) cont.remove(el)
files = new_files
id_mapping = {} id_mapping = {}
for el in model+files: for el in model+files:
...@@ -108,12 +88,10 @@ def main(filename, rerun=False): ...@@ -108,12 +88,10 @@ def main(filename, rerun=False):
# insert files # insert files
if not rerun: if not rerun:
for i, el in enumerate(files): for _, el in enumerate(files):
print(el)
r = el.insert(unique=False) r = el.insert(unique=False)
print(r)
else: else:
for i, el in enumerate(files): for _, el in enumerate(files):
el.id = None el.id = None
el.retrieve() el.retrieve()
......
...@@ -147,7 +147,7 @@ it is not at the beginning, it must be preceded by a blank line. ...@@ -147,7 +147,7 @@ it is not at the beginning, it must be preceded by a blank line.
raise ParseErrorsInHeader(filename, e) raise ParseErrorsInHeader(filename, e)
# except yaml.error.MarkedYAMLError as e: # except yaml.error.MarkedYAMLError as e:
# raise NoValidHeader(filename) # raise NoValidHeader(filename)
if type(yaml_part) != dict: if not isinstance(yaml_part, dict):
raise NoValidHeader(filename) raise NoValidHeader(filename)
return (found_1, found_2, clean_header(yaml_part)) return (found_1, found_2, clean_header(yaml_part))
...@@ -229,7 +229,7 @@ def clean_header(header): ...@@ -229,7 +229,7 @@ def clean_header(header):
for k, v in header.items(): for k, v in header.items():
# Plain string is put into list # Plain string is put into list
if type(v) == str: if isinstance(v, str):
header[k] = [v] header[k] = [v]
return header return header
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment