optimize a lot album generation by not regenerating when places are already generated
authorgc <gc>
Mon, 23 May 2005 19:14:17 +0000 (19:14 +0000)
committergc <gc>
Mon, 23 May 2005 19:14:17 +0000 (19:14 +0000)
bin/booh
bin/booh-backend

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 }
 
index b5f829ddf74dee1a4976c44ea89498fb59f5d12f..07ddebb7685895a8e394ea8a61b15eecf99d4402 100755 (executable)
@@ -50,6 +50,7 @@ $options = [
     [ '--merge-config-onedir',  '-O', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, for merging the subdir specified with --dir") ],
     [ '--dir',           '-D', GetoptLong::REQUIRED_ARGUMENT, _("Directory for merge with --merge-config-onedir") ],
     [ '--use-config',    '-u', GetoptLong::REQUIRED_ARGUMENT, _("File containing config listing, where to change theme info") ],
+    [ '--force',         '-f', GetoptLong::NO_ARGUMENT,       _("Force generation of album even if the GUI markes some directories as already generated") ],
 
     [ '--sizes',         '-S', GetoptLong::REQUIRED_ARGUMENT, _("Specify the list of images sizes to use instead of all specified in the theme (this is a comma-separated list)") ],
 
@@ -183,6 +184,9 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.") %
             when '--sizes'
                 $limit_sizes = arg
 
+            when '--force'
+                $force = true
+
             when '--mproc'
                 $mproc = arg.to_i
                 $pids = []
@@ -516,7 +520,8 @@ def walk_source_dir
         newly_created_dir = false
         xmldir = optxpath[utf8(dir)]
         if $mode == 'use_config' || $mode == 'use_config_changetheme'
-            if !xmldir
+            if !xmldir || (xmldir.attributes['already-generated'] && !$force)
+                info("walking: #{dir}, 0 elements")
                 next
             end
         else
@@ -531,6 +536,7 @@ def walk_source_dir
                 xmldir = optxpath[utf8(dir)] = xmldir.add_element('dir', { 'path' => utf8(dir) })
             end
         end
+        xmldir.delete_attribute('already-generated')
 
         #- read images/videos entries from config or from directories depending on mode
         entries = []
@@ -820,12 +826,13 @@ def walk_source_dir
 
     examined_dirs.each { |dir|
         dir.chomp!
+        info("index.html: #{dir}")
+
         xmldir = optxpath[utf8(dir)]
-        if !xmldir
+        if !xmldir || (xmldir.attributes['already-generated'] && !$force)
             next
         end
         dest_dir = make_dest_filename(dir.sub(/^#{Regexp.quote($source)}/, $dest))
-        info("index.html: #{dir}")
 
         if xmldir.elements['dir']
             html = $html_index.collect { |l| l.clone }