From 08691fb727bca33fda69a0ac112b96ae9700beba Mon Sep 17 00:00:00 2001 From: Carol Chou Date: Tue, 29 Nov 2011 11:10:37 -0500 Subject: [PATCH] clean up symlink in the event of HTTP 500 --- describe.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/describe.rb b/describe.rb index f0c69f2..2154cff 100644 --- a/describe.rb +++ b/describe.rb @@ -160,16 +160,10 @@ def get_config throw :halt, [400, "invalid url location"] end - - # make sure the file exist and it's a valid file if (File.symlink?(@input) || File.file?(@input)) then description - if io - io.unlink - else - FileUtils.rm link - end + FileUtils.rm @input else throw :halt, [404, "either #{@input} does not exist or it is not a valid file"] end @@ -214,7 +208,8 @@ def get_config @originalName = params['document'][:filename] # describe the transmitted file with format identifier and metadata description - File.delete(@input) + number = File.delete(@input) + puts "delete #{@input}, result #{number}" response.finish end @@ -222,6 +217,10 @@ def get_config [ 200, {'Content-Type' => 'application/xml'}, "\n" ] end +def cleanup +end + +# perform format description and generate the result in premis def description jhove = RJhove.instance droid = RDroid.instance @@ -242,7 +241,8 @@ def description rescue => e Datyl::Logger.err "running into exception #{e} while processing #{@originalName}" Datyl::Logger.err e.backtrace.join("\n") - throw :halt, [500, "running into exception #{e} while processing #{@originalName}\n#{e.backtrace.join('\n')}"] + FileUtils.rm @input + throw :halt, [500, "running into exception #{e} while processing #{@originalName}\n#{e.backtrace.join('\n')}"] end @formats.clear @@ -258,6 +258,7 @@ def description @result.clear @result = nil else + FileUtils.rm @input throw :halt, [500, "unexpected empty response while processing #{@originalName}"] end