Improved error handling if file already exists in file store (verify if file is corrupt in filesystem and remove it in case).
This commit is contained in:
parent
ce9ebe828f
commit
6c82931245
1 changed files with 11 additions and 0 deletions
|
@ -7,6 +7,17 @@ class Store::Provider::File
|
||||||
# install file
|
# install file
|
||||||
location = get_location(sha)
|
location = get_location(sha)
|
||||||
permission = '600'
|
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)
|
if !File.exist?(location)
|
||||||
Rails.logger.debug { "storge write '#{location}' (#{permission})" }
|
Rails.logger.debug { "storge write '#{location}' (#{permission})" }
|
||||||
file = File.new(location, 'wb')
|
file = File.new(location, 'wb')
|
||||||
|
|
Loading…
Reference in a new issue