optimize a lot album generation by not regenerating when places are already generated
[booh] / bin / booh
index cdb97008b1f56a659bc8b7dcb81b6360a52d7d1c..9707fa3488777d25248251fc6dbec641736eacf0 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -987,6 +987,7 @@ end
 
 def save_current_file
     save_changes
+
     if $filename
         ios = File.open($filename, "w")
         $xmldoc.write(ios, 0)
@@ -1107,7 +1108,7 @@ def backend_wait_message(parent, msg, infopipe_path, mode)
                 pb1_1.fraction = 1
             elsif line =~ /^creating index.html$/
                 pb1_2.text = utf8(_("finished"))
-                pb1_2.fraction = 1
+                pb1_1.fraction = pb1_2.fraction = 1
                 directories_counter = 0
             elsif line =~ /^index.html: (.+)/
                 newtext = utf8(full_src_dir_to_rel($1))
@@ -1174,6 +1175,8 @@ def save_changes(*forced)
         return
     end
 
+    $xmldir.delete_attribute('already-generated')
+
     if $xmldir.elements['dir']
         $xmldir.add_attribute('subdirs-caption', $subalbums_title.buffer.text)
         $xmldir.elements.each('dir') { |element|
@@ -2193,7 +2196,16 @@ def create_menu_and_toolbar
                      utf8(_("Please wait while generating web-album...\nThis may take a while, please be patient.")),
                      'web-album',
                      { :successmsg => utf8(_("Your web-album is now ready in directory `%s'.") % $xmldoc.root.attributes['destination']),
-                       :failuremsg => utf8(_("There was something wrong when generating the web-album, sorry.")) })
+                       :failuremsg => utf8(_("There was something wrong when generating the web-album, sorry.")),
+                       :closure_after => proc {
+                             $xmldoc.elements.each('//dir') { |elem|
+                                 elem.add_attribute('already-generated', 'true')
+                             }
+                             UndoHandler.cleanup   #- prevent save_changes to mark current dir as not already generated
+                             $undo_tb.sensitive = $undo_mb.sensitive = false
+                             $redo_tb.sensitive = $redo_mb.sensitive = false
+                             save_current_file
+                         }})
     }
     $properties.signal_connect('activate') { properties }