Permalink
Browse files

clean up symlink in the event of HTTP 500

  • Loading branch information...
1 parent f259e2f commit 08691fb727bca33fda69a0ac112b96ae9700beba @chouUF chouUF committed Nov 29, 2011
Showing with 10 additions and 9 deletions.
  1. +10 −9 describe.rb
View
@@ -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,14 +208,19 @@ 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
get '/status' do
[ 200, {'Content-Type' => 'application/xml'}, "<status/>\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

0 comments on commit 08691fb

Please sign in to comment.