Skip to content
Snippets Groups Projects
Commit 1180a186 authored by Gyan Gupta's avatar Gyan Gupta
Browse files

fixes for download sh file and dataset form thumbnail tab issue

parent 0bd11db0
Branches bug_fix/issue_20_35
No related tags found
2 merge requests!382fixes for download sh file and dataset form thumbnail tab issue,!346Draft: Hyrax 5 - Upgrade hyrax to v5
Pipeline #20641 failed
......@@ -33,7 +33,7 @@ class DownloadAllController < Hyrax::DownloadsController
redirect_to format: :zip
else
# async job redirects to show
build_shell_file unless has_shell_file?
build_shell_file
flash[:alert] = I18n.t('hyrax.notifications.preparing_download.message')
redirect_to main_app.polymorphic_path(work)
end
......@@ -79,7 +79,8 @@ class DownloadAllController < Hyrax::DownloadsController
def build_shell_file
shell_file = shell_file_path
cleanup_path(shell_file) if File.exist?(shell_file)
Hyrax::DownloadS3BucketJob.perform_later(current_user.id, work.id)
Hyrax::DownloadS3BucketJob.perform_later(current_user.id, work.id.to_s)
end
def build_zip_file(list_of_objects: nil)
......
......@@ -28,7 +28,11 @@ class DatasetForm < Hyrax::Forms::PcdmObjectForm(Dataset)
end
def tabs
%w[required description references funding dataset_thumbnail files relationships]
if self.persisted? && self.member_ids.any?
%w[required description references funding dataset_thumbnail files relationships]
else
%w[required description references funding files relationships]
end
end
def description_tab_terms
......
......@@ -42,6 +42,15 @@ module Hyrax
object
end
def after_file_metadata_updated_callbacks(file_set)
parent_work = file_set.parent_work
parent_work.set_format_and_size
parent_work = save_object!(parent_work)
Hyrax.index_adapter.save(resource: parent_work)
after_save_callbacks(parent_work)
end
def after_destroy_callbacks(object)
case object.class.name
when 'Crc1280Experiment', 'Dataset'
......
# frozen_string_literal: true
module Hyrax
class DownloadS3BucketJob < ApplicationJob
include Rails.application.routes.url_helpers
include DownloadHelper
def perform(current_user_id, work_id)
@work ||= Hyrax.query_service.find_by(id: work_id)
current_user = ::User.find_by(id: current_user_id)
unless has_shell_file?
s3 = S3StorageService.new
s3.init_client
s3.prepare_shell_file(work_id, shell_file_path)
end
if @work.is_a?(Crc1280Experiment)
path = hyrax_crc1280_experiment_path(work_id)
else
path = hyrax_dataset_path(work_id)
end
subject = I18n.t('hyrax.notifications.download_ready.subject')
message = I18n.t('hyrax.notifications.download_ready.message',
link: (ActionController::Base.helpers.link_to work_id, path),
download_link: (ActionController::Base.helpers.link_to :here, download_all_path(work_id, format: :sh)),
user: current_user.user_key)
Hyrax::MessengerService.deliver(current_user, current_user, message, subject)
end
def work
@work
end
end
end
......@@ -41,8 +41,18 @@ class HyraxListener
# def on_file_downloaded
# end
# def on_file_metadata_updated
# end
def on_file_metadata_updated(event)
return unless event[:metadata].original_file?
file_set = Hyrax.query_service.find_by(id: event[:metadata].file_set_id)
after_file_metadata_updated_callbacks(file_set)
Hyrax.index_adapter.save(resource: file_set)
rescue Valkyrie::Persistence::ObjectNotFoundError => err
Hyrax.logger.warn "tried to index file with id #{event[:metadata].id} " \
"in response to an event of type #{event.id} but " \
"encountered an error #{err.message}. should this " \
"object be in a FileSet #{event[:metadata]}"
end
# def on_file_metadata_deleted
# end
......
......@@ -33,7 +33,7 @@ module ExternalServices
s3 = S3StorageService.new
s3.init_client
_list_of_objects, size = s3.list_all_objects
size
[_list_of_objects.count, size]
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment