hopefully fixing the rest of potential aborts, thx to a suggestion from fif
authorgc <gc>
Sun, 29 Jan 2006 16:49:24 +0000 (16:49 +0000)
committergc <gc>
Sun, 29 Jan 2006 16:49:24 +0000 (16:49 +0000)
bin/booh
lib/booh/booh-lib.rb

index 0da74c0..ad765a1 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -2718,12 +2718,12 @@ def new_album
                 Thread.kill(src_nb_thread)
                 src_nb_thread = nil
             end
-            if File.directory?(from_utf8(src_nb_calculated_for)) && src_nb_calculated_for != '/'
-                if File.readable?(from_utf8(src_nb_calculated_for))
+            if File.directory?(from_utf8_safe(src_nb_calculated_for)) && src_nb_calculated_for != '/'
+                if File.readable?(from_utf8_safe(src_nb_calculated_for))
                     src_nb_thread = Thread.new {
                         gtk_thread_protect { src_nb.set_markup(utf8(_("<span size='small'><i>processing...</i></span>"))) }
                         total = { 'image' => 0, 'video' => 0, nil => 0 }
-                        `find '#{from_utf8(src_nb_calculated_for)}' -type d -follow`.each { |dir|
+                        `find '#{from_utf8_safe(src_nb_calculated_for)}' -type d -follow`.each { |dir|
                             if File.basename(dir) =~ /^\./
                                 next
                             else
index 1dc435e..e1a7e6f 100644 (file)
@@ -59,6 +59,14 @@ module Booh
         return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
     end
 
+    def from_utf8_safe(string)
+        begin
+            return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
+        rescue Iconv::IllegalSequence
+            return nil
+        end
+    end
+
     def make_dest_filename_old(orig_filename)
         #- we remove non alphanumeric characters but need to do that
         #- cleverly to not end up with two similar dest filenames. we won't