samvera / hydra-works

A ruby gem implementation of the PCDM Works domain model based on the Samvera software stack
Other
24 stars 14 forks source link

VirusCheckerService tries to access stream of FileSet that has not been saved #313

Closed carolyncole closed 7 years ago

carolyncole commented 7 years ago

The way the VirusCheckerService is being use in sufia/curation concerns, as a validation before save, causes the service to try and access a stream from an item that is not yet in the repository.

https://github.com/projecthydra/hydra-works/commit/796f8d12629b62442ac248e26cbe466e05e9828f#diff-8adc158121e9605cac64b6dc8574f678R30

The class of the content is a File in this case so we should be able to either use the existing code for items that do exists in the database !item.new_record? or Check for the content responding to path. I added return file.content.path if file.content.respond_to?(:path) in my local copy of the gem and that has fixed the problem.

I think the entire solution may be check the content for path, then check for new_record and return content and after that return the stream.