fix merging of config file (when adding image/videos in a
[booh] / bin / booh
index ba6ecb931818259f46e722f87c7c0f081d892b7b..d4feeaf960672db75992ac58f57170c523713091 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -300,7 +300,7 @@ def walk_source_dir
                 if !xmldir
                     xmldir = $xmldoc.root
                 end
-                xmldir = xmldir.add_element 'dir', { 'path' => utf8(dir), 'new' => 1 }
+                xmldir = xmldir.add_element 'dir', { 'path' => utf8(dir) }
             end
         end
 
@@ -514,7 +514,7 @@ def walk_source_dir
     #- add attributes to <dir..> elements needing so
     if $mode != 'use_config'
         msg 3, _("\tfixating configuration file...")
-        $xmldoc.elements.each('//dir[@new]') { |element|
+        $xmldoc.elements.each('//dir') { |element|
             path = captionpath = element.attributes['path']
             child = element
             captionfile = nil
@@ -532,14 +532,21 @@ def walk_source_dir
             end
             basename = File.basename(path)
             if element.elements['dir']
-                element.add_attribute('subdirs-caption', basename)
-                element.add_attribute('subdirs-captionfile', captionfile)
+                if !element.attributes['subdirs-caption']
+                    element.add_attribute('subdirs-caption', basename)
+                end
+                if !element.attributes['subdirs-captionfile']
+                    element.add_attribute('subdirs-captionfile', captionfile)
+                end
             end
             if element.elements['image'] || element.elements['video']
-                element.add_attribute('thumbnails-caption', basename)
-                element.add_attribute('thumbnails-captionfile', captionfile)
+                if !element.attributes['thumbnails-caption']
+                    element.add_attribute('thumbnails-caption', basename)
+                end
+                if !element.attributes['thumbnails-captionfile']
+                    element.add_attribute('thumbnails-captionfile', captionfile)
+                end
             end
-            element.delete_attribute('new')
         }
     end