--- wp-cache-phase2.php	2008-09-25 10:27:50.000000000 -0700
+++ wp-cache-phase2.php	2008-09-25 11:11:30.000000000 -0700
@@ -297,7 +297,7 @@
 	wp_cache_writers_exit();
 }
 
-function prune_super_cache($directory, $force = false, $rename = false) {
+function prune_super_cache($directory, $force = false, $rename = false, $recurse = true) {
 	global $cache_max_time, $cache_path, $super_cache_enabled;
 
 	if( !is_admin() && $super_cache_enabled == 0 )
@@ -316,7 +316,8 @@
 		$entries = glob($directory. '*');
 		if( is_array( $entries ) && !empty( $entries ) ) foreach ($entries as $entry) {
 			if ($entry != '.' && $entry != '..') {
-				prune_super_cache( $entry, $force, $rename );
+				if ( $recurse || !is_dir( $entry ) )
+					prune_super_cache( $entry, $force, $rename, $recurse );
 				if( is_dir( $entry ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
 					$oktodelete = true;
 					if( in_array( $entry, $protected_directories ) )
@@ -501,7 +502,7 @@
 		} else {
 			$permalink = trailingslashit( str_replace( get_option( 'home' ), '', post_permalink( $post_id ) ) );
 			$dir = $cache_path . 'supercache/' . $siteurl;
-			prune_super_cache( $dir . $permalink, true, true );
+			prune_super_cache( $dir . $permalink, true, true, false );
 			@rmdir( $dir . $permalink );
 			prune_super_cache( $dir . 'page/', true );
 		}
@@ -522,7 +523,7 @@
 						@unlink($meta_pathname);
 						@unlink($content_pathname);
 						if( $super_cache_enabled ) {
-							prune_super_cache( $cache_path . 'supercache/' . trailingslashit( $meta->uri ), true, true );
+							prune_super_cache( $cache_path . 'supercache/' . trailingslashit( $meta->uri ), true, true, false );
 						}
 					}
 				} elseif ($meta->blog_id == $blog_id) {
