#527 MD5 = 0 if the file is missing

This commit is contained in:
Karel Picman 2017-01-10 13:35:05 +01:00
parent 23c382190f
commit c7a30ca410
2 changed files with 7 additions and 14 deletions

View File

@ -3,7 +3,7 @@
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
#
# 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

View File

@ -2,7 +2,7 @@
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
#
# 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.create_digest
rev.save unless @dry_run
n += 1
end
# Progress bar
print "\r#{i * 100 / count}%"
end