From 3be9413d6818c3f58cb2219abceee3d4baa4547f Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Wed, 31 Oct 2012 11:42:19 +0100 Subject: [PATCH] Add minimal error handling. --- bin/cbr2cbz | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bin/cbr2cbz b/bin/cbr2cbz index 2a06702..21a9efc 100755 --- a/bin/cbr2cbz +++ b/bin/cbr2cbz @@ -2,6 +2,9 @@ require 'fileutils' +class UnrarError < RuntimeError ; end +class ZipError < RuntimeError ; end + where = Dir.pwd ARGV.each do |arg| @@ -12,11 +15,21 @@ ARGV.each do |arg| name = File.basename(arg).dup name.gsub!(/\.cbr/i,'') + if File.exists? name then + FileUtils.rm_rf name + end FileUtils.mkdir_p name Dir.chdir name system "unrar e \"#{cbr_path}\"" + if not $?.success? then + raise UnrarError + end + Dir.chdir where system "zip -r \"#{cbz_path}\" \"#{name}\"" + if not $?.success? then + raise ZipError + end FileUtils.rm_rf name end