diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index 8adc0cd4..5f8f8958 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -3,7 +3,7 @@ # Redmine plugin for Document Management System "Features" # # Copyright (C) 2011 Vít Jonáš -# Copyright (C) 2011-16 Karel Pičman +# Copyright (C) 2011-17 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -273,18 +273,12 @@ class DmsfFileRevision < ActiveRecord::Base Digest::MD5.file(path).hexdigest rescue Exception => e Rails.logger.error e.message - nil + 0 end end def create_digest - begin - self.digest = Digest::MD5.file(self.disk_file).hexdigest - true - rescue Exception => e - Rails.logger.error e.message - false - end + self.digest = DmsfFileRevision.create_digest(self.disk_file) end def tooltip diff --git a/lib/tasks/dmsf_create_digests.rake b/lib/tasks/dmsf_create_digests.rake index 628be4eb..61737ef0 100644 --- a/lib/tasks/dmsf_create_digests.rake +++ b/lib/tasks/dmsf_create_digests.rake @@ -2,7 +2,7 @@ # # Redmine plugin for Document Management System "Features" # -# Copyright (C) 2011-16 Karel Pičman +# Copyright (C) 2011-17 Karel Pičman # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -48,10 +48,9 @@ class DmsfDigest count = revisions.count n = 0 revisions.each_with_index do |rev, i| - if rev.create_digest - rev.save unless @dry_run - n += 1 - end + rev.create_digest + rev.save unless @dry_run + n += 1 # Progress bar print "\r#{i * 100 / count}%" end