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
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