Class: FixityCheckJob
- Inherits:
-
Hyrax::ApplicationJob
- Object
- ApplicationJob
- Hyrax::ApplicationJob
- FixityCheckJob
- Defined in:
- app/jobs/fixity_check_job.rb
Instance Method Summary collapse
-
#perform(uri, file_set_id:, file_id:) ⇒ Object
A Job class that runs a fixity check (using ActiveFedora::FixityService, which contacts fedora and requests a fixity check), and stores the results in an ActiveRecord ChecksumAuditLog row.
Instance Method Details
#perform(uri, file_set_id:, file_id:) ⇒ Object
A Job class that runs a fixity check (using ActiveFedora::FixityService, which contacts fedora and requests a fixity check), and stores the results in an ActiveRecord ChecksumAuditLog row. It also prunes old ChecksumAuditLog rows after creating a new one, to keep old ones you don’t care about from filling up your db.
The uri passed in is a fedora URI that fedora can run fixity check on. It’s normally a version URI like:
http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
But could theoretically be any URI fedora can fixity check on, like a file uri:
http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
The file_set_id and file_id are used only for logging context in the ChecksumAuditLog, and determining what old ChecksumAuditLogs can be pruned.
If calling async as a background job, return value is irrelevant, but if calling sync with ‘perform_now`, returns the ChecksumAuditLog record recording the check.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/jobs/fixity_check_job.rb', line 26 def perform(uri, file_set_id:, file_id:) uri = uri.to_s # sometimes we get an RDF::URI gah log = run_check(file_set_id, file_id, uri) if log.failed? && Hyrax.config.callback.set?(:after_fixity_check_failure) file_set = ::FileSet.find(file_set_id) Hyrax.config.callback.run(:after_fixity_check_failure, file_set, checksum_audit_log: log) end log end |