From 3f879e79da8120e476c334c8cabd2b56458200bc Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Tue, 6 Aug 2013 14:00:30 +0200 Subject: [PATCH] Ensure terminal gets released even in case of an exception --- app/services/snapshot_creator.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/services/snapshot_creator.rb b/app/services/snapshot_creator.rb index da2ce7e..3a54bba 100644 --- a/app/services/snapshot_creator.rb +++ b/app/services/snapshot_creator.rb @@ -4,10 +4,11 @@ class SnapshotCreator terminal = Terminal.new(width, height) seconds = (duration / 2).to_i bytes = stdout.bytes_until(seconds) - snapshot = terminal.feed(bytes) - terminal.release - snapshot + terminal.feed(bytes) + + ensure + terminal.release end end