From c4fa45266f2d4716a9dd5501984192d94724a62d Mon Sep 17 00:00:00 2001 From: Rory McNicholl Date: Fri, 19 Jan 2024 19:07:14 +0000 Subject: [PATCH 1/4] add safe nav for 'array_of_hash' (#511) --- .../shared/ubiquity/search_display/_show_array_hash.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb index dfae83f74..1e03d190a 100644 --- a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb +++ b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb @@ -1,4 +1,4 @@ -<% array_size = (array_of_hash.size <= 5 ? array_of_hash.size - 1 : 4) %> +<% array_size = (array_of_hash&.size <= 5 ? array_of_hash.size - 1 : 4) %> <% array_of_hash.each_with_index do |hash, index| %> <% if index <= 4 %> @@ -56,4 +56,4 @@ <% end %> <% end %> -<% end %> \ No newline at end of file +<% end %> From 522206b2c1f2b99ee70d86a7f95733031f113a29 Mon Sep 17 00:00:00 2001 From: Rory McNicholl Date: Fri, 19 Jan 2024 21:24:48 +0000 Subject: [PATCH 2/4] 509 need safe nav in ubiq view (#512) * add safe nav for 'array_of_hash' * handle odd case in which nil field ends up in view --- .../search_display/_show_array_hash.html.erb | 98 ++++++++++--------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb index 1e03d190a..c117c4928 100644 --- a/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb +++ b/app/views/shared/ubiquity/search_display/_show_array_hash.html.erb @@ -1,29 +1,17 @@ -<% array_size = (array_of_hash&.size <= 5 ? array_of_hash.size - 1 : 4) %> -<% array_of_hash.each_with_index do |hash, index| %> - <% if index <= 4 %> - - <% last_name = hash["#{attr_name}_family_name"] || '' %> - <% first_name = hash["#{attr_name}_given_name"] || '' %> - <% organizational_creator = hash["#{attr_name}_organization_name"] %> - <% last_name << ',' if last_name && display_comma?(hash.keys, ["#{attr_name}_family_name", "#{attr_name}_given_name"]) %> - <% document.creator_search.each do |creator| %> - - <% if creator == organizational_creator %> - <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(organizational_creator)}), class: 'creator-search-results' do %> - <%= organizational_creator %> - <%= remove_last_semicolon(array_size, index) %> - <% if index != array_size %> -   - <% end %> - <%= '…' if index == array_size && array_of_hash.size > 5 %> - <% end %> - <% end %> - <% if last_name %> - <% if creator == "#{last_name} " + first_name || - creator + first_name == "#{last_name} " + first_name %> - <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name + (" #{first_name}" if first_name)) }), class: 'creator-search-results' do %> - <%= last_name %> - <%= first_name if first_name %> +<% if array_of_hash.present? %> + <% array_size = (array_of_hash&.size <= 5 ? array_of_hash.size - 1 : 4) %> + <% array_of_hash.each_with_index do |hash, index| %> + <% if index <= 4 %> + + <% last_name = hash["#{attr_name}_family_name"] || '' %> + <% first_name = hash["#{attr_name}_given_name"] || '' %> + <% organizational_creator = hash["#{attr_name}_organization_name"] %> + <% last_name << ',' if last_name && display_comma?(hash.keys, ["#{attr_name}_family_name", "#{attr_name}_given_name"]) %> + <% document.creator_search.each do |creator| %> + + <% if creator == organizational_creator %> + <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(organizational_creator)}), class: 'creator-search-results' do %> + <%= organizational_creator %> <%= remove_last_semicolon(array_size, index) %> <% if index != array_size %>   @@ -31,29 +19,43 @@ <%= '…' if index == array_size && array_of_hash.size > 5 %> <% end %> <% end %> - <% if creator == last_name %> - <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name) }), class: 'creator-search-results' do %> - <%= last_name %> - <%= remove_last_semicolon(array_size, index) %> - <% if index != array_size %> -   - <% end %> - <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% if last_name %> + <% if creator == "#{last_name} " + first_name || + creator + first_name == "#{last_name} " + first_name %> + <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name + (" #{first_name}" if first_name)) }), class: 'creator-search-results' do %> + <%= last_name %> + <%= first_name if first_name %> + <%= remove_last_semicolon(array_size, index) %> + <% if index != array_size %> +   + <% end %> + <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% end %> <% end %> - <% end %> - <% if creator == first_name %> - <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(first_name) }), class: 'creator-search-results' do %> - <%= first_name %> - <%= remove_last_semicolon(array_size, index) %> - <% if index != array_size %> -   - <% end %> - <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% if creator == last_name %> + <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(last_name) }), class: 'creator-search-results' do %> + <%= last_name %> + <%= remove_last_semicolon(array_size, index) %> + <% if index != array_size %> +   + <% end %> + <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% end %> <% end %> - <% end %> - <% end %> - - <% end %> - + <% if creator == first_name %> + <%= link_to main_app.search_catalog_path(f: { creator_search_sim: Array(first_name) }), class: 'creator-search-results' do %> + <%= first_name %> + <%= remove_last_semicolon(array_size, index) %> + <% if index != array_size %> +   + <% end %> + <%= '…' if index == array_size && array_of_hash.size > 5 %> + <% end %> + <% end %> + <% end %> + + <% end %> + + <% end %> <% end %> <% end %> From a8b6868030d07c7c160a3d9ba775f472e43c283f Mon Sep 17 00:00:00 2001 From: Rory McNicholl Date: Mon, 29 Jan 2024 20:46:37 +0000 Subject: [PATCH 3/4] return av, but not the gem yet (#513) --- Dockerfile | 8 ++++++++ bin/worker | 2 +- docker-compose.production.yml | 2 +- docker-compose.yml | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index b9b3a828a..8b4cef213 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ USER root RUN apk --no-cache upgrade && \ apk --no-cache add \ bash \ + clamav \ + clamav-daemon \ cmake \ exiftool \ ffmpeg \ @@ -35,6 +37,11 @@ RUN apk --no-cache upgrade && \ # cargo install rbspy && \ echo "******** Packages Installed *********" +RUN sed -i 's/User clamav/User app/g' /etc/clamav/clamd.conf +RUN mkdir -p /var/run/clamav && chown -R app:app /var/run/clamav +RUN mkdir -p /var/log/clamav && chown -R app:app /var/log/clamav +RUN chown -R app:app /var/lib/clamav + RUN wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-57.tar.gz \ && tar xf 7.1.0-57.tar.gz \ && apk --no-cache add \ @@ -98,5 +105,6 @@ RUN RAILS_ENV=production SECRET_KEY_BASE=`bin/rake secret` DB_ADAPTER=nulldb DAT CMD ./bin/web FROM hyku-web as hyku-worker +RUN freshclam ENV MALLOC_ARENA_MAX=2 CMD ./bin/worker diff --git a/bin/worker b/bin/worker index b7605486b..2d33ecb79 100755 --- a/bin/worker +++ b/bin/worker @@ -9,4 +9,4 @@ else puts 'DATABASE_URL not set, no pool change needed' end -exec "echo $DATABASE_URL && bundle exec sidekiq" +exec "echo $DATABASE_URL && clamd && bundle exec sidekiq" diff --git a/docker-compose.production.yml b/docker-compose.production.yml index 49ea47332..3ec7ab3b8 100644 --- a/docker-compose.production.yml +++ b/docker-compose.production.yml @@ -126,7 +126,7 @@ services: target: hyku-worker args: - HYKU_BULKRAX_ENABLED=true - command: bundle exec sidekiq + command: clamd && bundle exec sidekiq depends_on: - check_volumes - db diff --git a/docker-compose.yml b/docker-compose.yml index 9221cb824..046eafafa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -182,7 +182,7 @@ services: ## ## With the following line, uncommented during active development, we'll ## run bundle then run sidekiq. - # command: sh -l -c "bundle && bundle exec sidekiq" + command: sh -l -c "clamd && bundle && bundle exec sidekiq" ## ## Similar to the above, except we will bundle and then tell the container ## to wait. You'll then need to bash into the worker container and start From f12b25ccbaf1b68b0ca337f95f38ab109ee952d4 Mon Sep 17 00:00:00 2001 From: Rory McNicholl Date: Wed, 7 Feb 2024 13:48:13 +0000 Subject: [PATCH 4/4] comment out video derivative that makes webm (#500) --- config/initializers/file_set_derivatives_overrides.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/file_set_derivatives_overrides.rb b/config/initializers/file_set_derivatives_overrides.rb index 35a33c14d..baa9ad47f 100644 --- a/config/initializers/file_set_derivatives_overrides.rb +++ b/config/initializers/file_set_derivatives_overrides.rb @@ -51,8 +51,8 @@ def create_video_derivatives(filename) Hydra::Derivatives::VideoDerivatives.create(filename, outputs: [{ label: :thumbnail, format: 'jpg', url: derivative_url('thumbnail') }, - { label: 'webm', format: 'webm', - url: derivative_url('webm') }, +# { label: 'webm', format: 'webm', +# url: derivative_url('webm') }, { label: 'mp4', format: 'mp4', url: derivative_url('mp4') }]) end