New file usage logic for json_form_widget #3730
Merged
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.
File usage for uploaded files on the form was broken. This PR:
QA Steps
Issues
Delete hook
The new delete hook could be expensive in certain scenarios -- either sites with a lot of content types and functionality beyond DKAN, or very large catalogs. If we see issues in any implementations or from the community we could add a configuration setting to make the delete behavior optional.
Orphans
Most of the point of this was to make orphaned files go away after deleting a dataset.
If this new behavior is used in combination with setting
file.settings:make_unused_managed_files_temporary
totrue
, files will be set to "temporary" status as well once their parent dataset is deleted. This will cause them to be deleted after 6 hours (or whatever you have set insystem.file:temporary_maximum_age
.But, maybe we shouldn't do or recommend this for now:
I'd recommend we add this for now and keep our eye on the file usage. We may want to install file_delete so that we can manually delete files once we see they are unused. In the future we can experiment with the
make_unused_managed_files_temporary
setting or even adding our own logic to the module that sets the unused json_form_widget files to temporary automatically.Tests
My understanding is that we still do not have a reliable way to test file uploads with cypress. Also all the code here is in the .module file; I don't actually know how to test this properly.