Skip to content

Commit

Permalink
io.schema: Prohibit directories in resource names
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Mar 26, 2020
1 parent a29a305 commit 4ffc525
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion kcidb/io/schema/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"type": "string",
"description":
"Resource name. Must be usable as a local file name for the "
"downloaded resource.",
"downloaded resource. Cannot be empty. Should not include "
"directories.",
"pattern": "^[^/]+$",
},
"url": {
"type": "string",
Expand Down Expand Up @@ -537,6 +539,16 @@ def inherit(data):
del obj[pair[0]]
del obj[pair[1]]

# Replace slashes with underscores in resource names
for collection, prop_list in \
dict(revisions=["patch_mboxes"],
builds=["input_files", "output_files"],
tests=["output_files"]).items():
for obj in data.get(collection, []):
for prop in prop_list:
for resource in obj[prop]:
resource["name"] = resource["name"].replace("/", "_")

# Update version
data['version'] = dict(major=JSON_VERSION_MAJOR,
minor=JSON_VERSION_MINOR)
Expand Down

0 comments on commit 4ffc525

Please sign in to comment.