Story#119627029 - save checksum of legal doc to DB

(cherry picked from commit dd3f19c)
This commit is contained in:
Vladimir Krylov 2016-08-01 16:01:52 +03:00
parent 5ed949efc6
commit cd81a3d356

View file

@ -33,6 +33,7 @@ class LegalDocument < ActiveRecord::Base
def save_to_filesystem
binary = Base64.decode64(body)
digest = Digest::SHA1.new.update(binary).to_s
loop do
rand = SecureRandom.random_number.to_s.last(4)
@ -45,7 +46,7 @@ class LegalDocument < ActiveRecord::Base
File.open(path, 'wb') { |f| f.write(binary) } unless Rails.env.test?
self.path = path
self.checksum = digest
end
def calc_checksum