don't incidentally remove thumbnails images in gen_config mode
authorgc <gc>
Mon, 1 Aug 2005 21:17:41 +0000 (21:17 +0000)
committergc <gc>
Mon, 1 Aug 2005 21:17:41 +0000 (21:17 +0000)
bin/booh-backend

index 0a1e341d0a3b94d70562eaf3ee06fbcd4891e18c..157e36ac34e32a2accb9e7edc5203c070fcac69f 100755 (executable)
@@ -623,21 +623,25 @@ def walk_source_dir
             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 CVS).include?(e) }
-                rightful_images = []
-                if xmldir.attributes['thumbnails-caption']
-                    rightful_images << 'thumbnails-thumbnail.jpg'
-                end
-                xmldir.elements.each('dir') { |child|
-                    if child.attributes['deleted']
-                        next
+                                find_all { |e| !%w(. .. skeleton_image.html skeleton_thumbnails.html skeleton_index.html metadata CVS).include?(e) }
+                if $mode != 'gen_config'
+                    rightful_images = []
+                    if xmldir.attributes['thumbnails-caption']
+                        rightful_images << 'thumbnails-thumbnail.jpg'
                     end
-                    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?("#{dest_dir}/#{e}") && !rightful_images.include?(e) } - themestuff
-                system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' '))
-
+                    xmldir.elements.each('dir') { |child|
+                        if child.attributes['deleted']
+                            next
+                        end
+                        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?("#{dest_dir}/#{e}") && !rightful_images.include?(e) } - themestuff
+                    if to_del.size > 0
+                        system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' '))
+                    end
+                end
+                
                 #- copy any resource file that goes with the theme (css, images..)
                 themestuff.each { |entry|
                     if !File.exists?("#{dest_dir}/#{entry}")
@@ -729,7 +733,9 @@ def walk_source_dir
                      concat(thumbnail_videos.collect { |e| e[1] }.flatten).
                      concat(videos)
             to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?("#{dest_dir}/#{e}") && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } - themestuff
-            system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' '))
+            if to_del.size > 0
+                system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' '))
+            end
 
             #- copy any resource file that goes with the theme (css, images..)
             themestuff.each { |entry|