From 243368a758a60f73c654e86716b452c6a7b87f98 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Mon, 18 Jan 2016 15:58:00 -0800 Subject: [PATCH] fixes #2569 --- app/models/upload.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/upload.rb b/app/models/upload.rb index 084f44bc2..6ce63dd7e 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -73,6 +73,12 @@ class Upload < ActiveRecord::Base end end + def validate_md5_confirmation_after_move + if !md5_confirmation.blank? && md5_confirmation != Digest::MD5.file(md5_file_path).hexdigest + raise "md5 mismatch" + end + end + def rating_given if rating.present? return true @@ -121,6 +127,7 @@ class Upload < ActiveRecord::Base end generate_resizes(file_path) move_file + validate_md5_confirmation_after_move save post = convert_to_post post.distribute_files @@ -191,6 +198,7 @@ class Upload < ActiveRecord::Base end def move_file + return if File.exists?(md5_file_path) FileUtils.mv(file_path, md5_file_path) end