Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contentUrl when fetching remote files #170

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading