Skip to content
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

Merged
merged 2 commits into from
Nov 24, 2015

Conversation

grosscol
Copy link
Contributor

Allow use of File in FileSetActor create_content.
Don't depend on original_filename and content_type.
Use AddFileToFileSet to avoid extra calls to save from IngestFileJob.
Update yard docs to indicate File as valid param type.
closes #456


# Assign label and title of File Set after original_name has been determined.
file_set.label ||= file_set.original_file.original_name
file_set.title = [file_set.label] if file_set.title.blank?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting file_set.title here does not get persisted according to the specs, and I'm baffled as to why that is the case.

# @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)
name = file.respond_to?(:original_filename) ? file.original_filename : ::File.basename(file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we use file_set.label here (or pass it as a parameter)? Then we avoid repeating this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I was reluctant to change any function signatures, but I did not notice that this one is marked private. I'll update this to do the respond_to check once and then pass along the result where needed.

@jcoyne
Copy link
Contributor

jcoyne commented Nov 16, 2015

Please add a couple of tests to this PR.

@grosscol grosscol force-pushed the issue_456 branch 2 times, most recently from f2f8f8f to ba7b6ce Compare November 18, 2015 21:42
@grosscol
Copy link
Contributor Author

A few tests added.

described_class.perform_now(file_set.id, filename, 'image/png', 'bob')
expect(file_set.reload.original_file.mime_type).to eq 'image/png'
end

it 'does not decorate File when not given mime_type' do
allow(CurationConcerns::VersioningService).to receive(:create)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should VersioningService ever be called? wasn't versioning: false going to prevent it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to versioning: false is an instruction to the Hydra::Works machinery so that the CurationConcerns machinery can do its own versioning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 Thanks for the explanation.

grosscol and others added 2 commits November 23, 2015 15:07
Allow use of File in FileSetActor create_content.
Don't depend on original_filename and content_type.
Use AddFileToFileSet to avoid extra calls to save from IngestFileJob.
Update yard docs to indicate File as valid param type.
Add specs to cover cases for using ::File as input to FileSetActor
functions.
# @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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

jcoyne added a commit that referenced this pull request Nov 24, 2015
Handle ingest of File from IngestLocalFileJob
@jcoyne jcoyne merged commit d367bdc into samvera-deprecated:master Nov 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IngestLocalFile job attempts to use non-existant method original_filename
3 participants