From: Peter Amstutz Date: Fri, 4 Nov 2022 01:14:00 +0000 (-0400) Subject: 19699: Ensure collection name doesn't go over the limit X-Git-Tag: 2.5.0~37^2~7 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/cc686b375dc80b5e8e7d471b4bb663fb879f221b 19699: Ensure collection name doesn't go over the limit Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/sdk/cwl/arvados_cwl/http.py b/sdk/cwl/arvados_cwl/http.py index dcc2a51192..b061f44f96 100644 --- a/sdk/cwl/arvados_cwl/http.py +++ b/sdk/cwl/arvados_cwl/http.py @@ -151,6 +151,15 @@ def http_to_keep(api, project_uuid, url, utcnow=datetime.datetime.utcnow): collectionname = "Downloaded from %s" % urllib.parse.quote(url, safe='') + + # max length - space to add a timestamp used by ensure_unique_name + max_name_len = 254 - 28 + + if len(collectionname) > max_name_len: + over = len(collectionname) - max_name_len + split = int(max_name_len/2) + collectionname = collectionname[0:split] + "…" + collectionname[split+over:] + c.save_new(name=collectionname, owner_uuid=project_uuid, ensure_unique_name=True) api.collections().update(uuid=c.manifest_locator(), body={"collection":{"properties": properties}}).execute()