Repository navigation
Name dumps after the live CKAN resource - #34
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs datopian/neso-nextgen-shared#7 (UAT: download filename keeps the old name after a file is replaced)
The problem, in plain words
When someone replaces an uploaded file, CKAN updates the file's address (url) to the new name. But the datastore does not ask CKAN for the address each time. It keeps a saved copy of CKAN's answer for up to an hour (
AUTH_CACHE_TTL=3600), and it built the download name from that saved copy. So for up to an hour after a replace, downloads in ndjson, gzip, parquet and the other dump formats still got the old file name. If someone had downloaded right after the first upload, they kept getting the first name.The fix
Before naming a download, the datastore now asks CKAN (
resource_show) for the current resource. The saved copy is still used for the permission check, so nothing gets slower or less safe there. If CKAN cannot be reached, it falls back to the saved copy so a download never fails because of this.What changed
datastore/infrastructure/ckan_client.py: newresource_showcall.datastore/api/context.py: newRequestContext.fresh_resource(), live resource with a fallback to the cached one.datastore/api/endpoints/dump.py:dump,dump_sql, and the data dictionary and metadata downloads now name the file from the live resource.tests/conftest.py,tests/test_datastore_dump.py: the fake CKAN can now report a stale resource, plus two new tests (stale cache after a replace gets the new name; CKAN failure falls back to the cached name).Verified
ruff checkandruff formatclean.mainand passes with this change.urlwassellorder-validate-c.csv, but the ndjson dump was still namedpersonal.json.Not verified / leftovers
Deployment
Merging does not deploy anything by itself. CI only runs tests. dx-helm-neso builds the datastore image from a pinned
DATASTORE_REFindatastore/Dockerfile(currently34a7370), so after merge that ref has to be bumped in dx-helm-neso and released to dev.