save uploads under their key, not their title #18

Merged
adina merged 1 commit from adina/tools:pid into main 2026-02-10 11:46:55 +00:00

View file

@ -60,8 +60,8 @@ class AnnexRegistrator(object):
Compute the target path for a file in the repository. Compute the target path for a file in the repository.
# attachments/ # attachments/
# schema-type/ # schema-type/
# pid/ # pid-distribution-of/
# title.ext # key
:param info: A dictionary with information about the file :param info: A dictionary with information about the file
:param pid_transformation: A function to perform string substitution :param pid_transformation: A function to perform string substitution
to sanitize paths to sanitize paths
@ -69,7 +69,7 @@ class AnnexRegistrator(object):
file_path =\ file_path =\
f'attachments/{pid_transformation(info["schema"])}/' \ f'attachments/{pid_transformation(info["schema"])}/' \
f'{pid_transformation(info["pid"])}/' \ f'{pid_transformation(info["pid"])}/' \
f'{pid_transformation(info["title"])}' f'{pid_transformation(info["key"])}'
return file_path return file_path
def register(self) -> None: def register(self) -> None:
@ -125,7 +125,7 @@ class AnnexRegistrator(object):
# TODO: change keys/placeholder later once structure of records is # TODO: change keys/placeholder later once structure of records is
# known # known
self.mapping[key] =\ self.mapping[key] =\
{'title': dist_record.get('display_label', 'placeholder'), {'key': key,
'schema': dist_record.get('schema_type', 'placeholder'), 'schema': dist_record.get('schema_type', 'placeholder'),
'pid': dist_record.get('pid', 'placeholder'), 'pid': dist_record.get('pid', 'placeholder'),
} }