enabled netCDF file in a composite resource to run script when being set to public
@@ -1752,8 +1752,20 @@ class AbstractResource(ResourcePermissionsMixin, ResourceIRODSMixin):
# TODO: why does this only run when something becomes public?
# TODO: Should it be run when a NetcdfResource becomes private?
- # run script to update hyrax input files when private netCDF resource changes state
- if value and settings.RUN_HYRAX_UPDATE and self.resource_type == 'NetcdfResource':
+ # Anwser to TODO above: it is intentional not to run it when a target resource
+ # becomes private for performance reasons. The nightly script run will clean up
+ # to make sure all private resources are not available to hyrax server.
+ # run script to update hyrax input files when private netCDF resource becomes
+ # public or private composite resource that includes netCDF files becomes public
+
+ is_netcdf_to_public = False
+ if self.resource_type == 'NetcdfResource':
+ is_netcdf_to_public = True
+ elif self.resource_type == 'CompositeResource' and \
+ self.get_logical_files('NetCDFLogicalFile'):
+ is_netcdf_to_public = True
+
+ if value and settings.RUN_HYRAX_UPDATE and is_netcdf_to_public:
run_script_to_update_hyrax_input_files(self.short_id)
def set_require_download_agreement(self, user, value):
