curationexperts / mahonia

Oregon Health & Science Repository
Apache License 2.0
6 stars 0 forks source link

Add basic virus checking with logging and file deletion #282

Closed no-reply closed 6 years ago

no-reply commented 6 years ago

Virus handling is added to AttachFilesToWorkJob (which unfortunately must be copied wholesale from Hyrax).

By default Hyrax embeds virus checking in the model validations, which means a real Hydra::PCDM::File must exist in order to check for a virus and handle errors. This is somewhat challenging in the case that we want to check asynchonously and handle errors, since a File doesn't exist until an ImportJob is running; in the default actor stack, this is several asynchonous jobs deep.

By adding an early check, we can avoid creating a FileSet for files that contain a virus, and add error handling earlier in the stack. In this case, we log to Rails.logger.error.

We also clean up the file from disk, which Hyrax does not seem to bother with(?).

Closes #178.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-0.05%) to 98.158% when pulling b0e97638ed7a3c0047bcff7e57f010e8549d4d7f on basic-virus-checking into 8003c4a38d442ba72d2d408a3b6f5670c842402b on master.