From 6c8293124581573b584776eda0d2b2071914ba3c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 26 Sep 2018 10:06:48 +0200 Subject: [PATCH] Improved error handling if file already exists in file store (verify if file is corrupt in filesystem and remove it in case). --- app/models/store/provider/file.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/store/provider/file.rb b/app/models/store/provider/file.rb index d454612ff..153872441 100644 --- a/app/models/store/provider/file.rb +++ b/app/models/store/provider/file.rb @@ -7,6 +7,17 @@ class Store::Provider::File # install file location = get_location(sha) permission = '600' + + # verify if file already is in file system and if it's not corrupt + if File.exist?(location) + begin + get(sha) + rescue + delete(sha) + end + end + + # write file to file system if !File.exist?(location) Rails.logger.debug { "storge write '#{location}' (#{permission})" } file = File.new(location, 'wb')