make sure to have correct theme stuff when changing theme by always copying theme...
authorgc <gc>
Sat, 19 Apr 2008 14:06:11 +0000 (14:06 +0000)
committergc <gc>
Sat, 19 Apr 2008 14:06:11 +0000 (14:06 +0000)
bin/booh-backend

index 3fe5564d678b6872a23ae9276f09c264cc6ae262..d78ba9beab32396856b1b1d264497eaecaa25f0c 100755 (executable)
@@ -876,10 +876,6 @@ def walk_source_dir
         if images.size == 0 && videos.size == 0
             if !$forgui
                 #- cleanup old images/videos, especially if this directory contained images/videos previously.
-                themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
-                                find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
-                themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
-                                     find_all { |e| !%w(. .. CVS).include?(e) }
                 if $mode != 'gen_config'
                     rightful_images = [ '.htaccess' ]
                     if xmldir.attributes['thumbnails-caption']
@@ -892,13 +888,15 @@ def walk_source_dir
                         subdir = make_dest_filename(from_utf8(File.basename(child.attributes['path'])))
                         rightful_images << "thumbnails-#{subdir}.jpg"
                     }
-                    to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !rightful_images.include?(e) } - themestuff - themestuff_root
+                    to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !rightful_images.include?(e) }
                     if to_del.size > 0
                         File.delete(*to_del.collect { |e| File.join(dest_dir, e) })
                     end
                 end
                 
                 #- copy any resource file that goes with the theme (css, images..)
+                themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
+                                 find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
                 themestuff.each { |entry|
                     if !File.exists?(File.join(dest_dir, entry))
                         psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'")
@@ -907,6 +905,8 @@ def walk_source_dir
 
                 #- copy any root-only resource file that goes with the theme (css, images..)
                 if xmldir.parent.name != 'dir'
+                    themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
+                                          find_all { |e| !%w(. .. CVS).include?(e) }
                     themestuff_root.each { |entry|
                         if !File.exists?(File.join(dest_dir, entry))
                             psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'")
@@ -1021,25 +1021,22 @@ def walk_source_dir
             end
         }
 
-        if !$forgui
-            themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
-                            find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
-            themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
-                                 find_all { |e| !%w(. .. CVS).include?(e) }
-            
+        if !$forgui            
             #- cleanup old images/videos (for when removing elements or sizes)
             all_elements = fullscreen_images.collect { |e| e[1] }.flatten.
                      concat(thumbnail_images.collect { |e| e[1] }.flatten).
                      concat(thumbnail_videos.collect { |e| e[1] }.flatten).
                      concat($transcode_videos ? transcoded_videos.values : videos).
                      push('.htaccess')
-            to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } - themestuff - themestuff_root
+            to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ }
             if to_del.size > 0
                 msg 3, _("\tcleaning up: #{to_del.join(', ')}")
                 File.delete(*to_del.collect { |e| File.join(dest_dir, e) })
             end
 
             #- copy any resource file that goes with the theme (css, images..)
+            themestuff = Dir.entries("#{$FPATH}/themes/#{$theme}").
+                             find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata root CVS).include?(e) }
             themestuff.each { |entry|
                 if !File.exists?(File.join(dest_dir, entry))
                     psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'")
@@ -1048,6 +1045,8 @@ def walk_source_dir
             
             #- copy any root-only resource file that goes with the theme (css, images..)
             if xmldir.parent.name != 'dir'
+                themestuff_root = Dir.entries("#{$FPATH}/themes/#{$theme}/root").
+                                      find_all { |e| !%w(. .. CVS).include?(e) }
                 themestuff_root.each { |entry|
                     if !File.exists?(File.join(dest_dir, entry))
                         psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'")