Skip to content

Commit

Permalink
add contentUrl when fetching remote files
Browse files Browse the repository at this point in the history
  • Loading branch information
simleo committed Dec 22, 2023
1 parent 7364e13 commit 26ee9e9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions rocrate/model/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def write(self, base_path):
if self.fetch_remote:
out_file_path.parent.mkdir(parents=True, exist_ok=True)
urllib.request.urlretrieve(response.url, out_file_path)
self._jsonld['contentUrl'] = str(self.source)
elif self.source is None:
# Allows to record a File entity whose @id does not exist, see #73
warnings.warn(f"No source for {self.id}")
Expand Down
1 change: 1 addition & 0 deletions test/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def test_remote_uri(tmpdir, helpers, fetch_remote, validate_url, to_zip):
if fetch_remote:
out_file = out_crate.dereference(file_.id)
assert (out_path / relpath).is_file()
assert out_file["contentUrl"] == url
else:
out_file = out_crate.dereference(url)
assert not (out_path / relpath).exists()
Expand Down

0 comments on commit 26ee9e9

Please sign in to comment.