protect against disappeared videos
authorgc <gc>
Thu, 5 May 2005 21:35:17 +0000 (21:35 +0000)
committergc <gc>
Thu, 5 May 2005 21:35:17 +0000 (21:35 +0000)
bin/booh-gui
lib/booh/booh-lib.rb

index 823d8faf8d01aba8ddd012be4c34266ce015f19c..81b531a5c62fbb2f2b0bd20753e2358c5b7f82d6 100755 (executable)
@@ -448,7 +448,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption)
 
     tooltips = Gtk::Tooltips.new
     tipname = File.basename(thumbnail_img).gsub(/-\d+x\d+\.jpg/, '')
 
     tooltips = Gtk::Tooltips.new
     tipname = File.basename(thumbnail_img).gsub(/-\d+x\d+\.jpg/, '')
-    tooltips.set_tip(evtbox, utf8(type == 'video' ? (_("%s (video - %s KB)") % [tipname, commify(File.size(from_utf8("#{$current_path}/#{filename}"))/1024)]) : tipname), nil)
+    tooltips.set_tip(evtbox, utf8(type == 'video' ? (_("%s (video - %s KB)") % [tipname, commify(file_size(from_utf8("#{$current_path}/#{filename}"))/1024)]) : tipname), nil)
 
     frame2, textview = create_editzone($autotable_sw, 1)
     textview.buffer.text = utf8(caption)
 
     frame2, textview = create_editzone($autotable_sw, 1)
     textview.buffer.text = utf8(caption)
index b79a1d3b7147230ef03a59bbc96c71d305f7ea62..e2dc096d6f4de140726a520d48463055369b23a8 100644 (file)
@@ -329,4 +329,12 @@ module Booh
         type = find_subalbum_info_type(xmldir)
         return from_utf8(xmldir.attributes["#{type}-captionfile"]), xmldir.attributes["#{type}-caption"]
     end
         type = find_subalbum_info_type(xmldir)
         return from_utf8(xmldir.attributes["#{type}-captionfile"]), xmldir.attributes["#{type}-caption"]
     end
+
+    def file_size(path)
+        begin
+            return File.size(path)
+        rescue
+            return -1
+        end
+    end
 end
 end