-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle ingest of File from IngestLocalFileJob #460
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,14 +46,18 @@ def create_metadata(upload_set_id, work, file_set_params = {}) | |
# Simultaneously moving a preservation copy to the repostiory. | ||
# TODO: create a job to monitor this directory and prune old files that | ||
# have made it to the repo | ||
# @param [ActionDigest::HTTP::UploadedFile, Tempfile] file the file uploaded by the user. | ||
# @param [File, ActionDigest::HTTP::UploadedFile, Tempfile] file the file uploaded by the user. | ||
def create_content(file) | ||
file_set.label ||= file.original_filename | ||
# Assign label and title of File Set is necessary. | ||
file_set.label ||= file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file) | ||
file_set.title = [file_set.label] if file_set.title.blank? | ||
|
||
# Need to save the file_set in order to get an id | ||
return false unless file_set.save | ||
|
||
working_file = copy_file_to_working_directory(file, file_set.id) | ||
IngestFileJob.perform_later(file_set.id, working_file, file.content_type, user.user_key) | ||
mime_type = file.respond_to?(:content_type) ? file.content_type : nil | ||
IngestFileJob.perform_later(file_set.id, working_file, mime_type, user.user_key) | ||
make_derivative(file_set.id, working_file) | ||
true | ||
end | ||
|
@@ -103,11 +107,13 @@ def make_derivative(file_set_id, working_file) | |
CharacterizeJob.perform_later(file_set_id, working_file) | ||
end | ||
|
||
# @param [ActionDispatch::Http::UploadedFile] file | ||
# @param [File, ActionDispatch::Http::UploadedFile] file | ||
# @param [String] id the identifer | ||
# @return [String] path of the working file | ||
def copy_file_to_working_directory(file, id) | ||
copy_stream_to_working_directory(id, file.original_filename, file) | ||
# file_set.label not gaurunteed to be set at this point (e.g. if called from update_content) | ||
file_set.label ||= file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. label has already been set on line 52. Is there ever a case it gets here without a label set? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that it could get called from update_content, but in that case file_set never gets saved, so it's not required, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec seemed to imply that a potential use case was updating a file_set which had no content to begin with so the label would not have already been set. I assumed the file_set to be saved after the update. |
||
copy_stream_to_working_directory(id, file_set.label, file) | ||
end | ||
|
||
# @param [FileSet] file_set the resource | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing
file_set.title = [file_set.label] if file_set.title.blank?
here satisfies the tests. Putting the same line in the IngestFileJob does not persist the title.The failing test is https://github.com/projecthydra-labs/curation_concerns/blob/master/spec/actors/curation_concerns/file_set_actor_spec.rb#L97