From 4e95b575a6d495f3fde0085947a85ecbdd9dcba1 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 23 Jul 2007 17:21:20 +0000 Subject: [PATCH] Seed subdirs in the deleted zone with a blank index.html file, to prevent crawling. --- includes/filerepo/FSRepo.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index d5a6783e05..d3d1b70c92 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -142,8 +142,15 @@ class FSRepo extends FileRepo { $dstPath = "$root/$dstRel"; $dstDir = dirname( $dstPath ); - if ( !is_dir( $dstDir ) && !wfMkdirParents( $dstDir ) ) { - return $this->newFatal( 'directorycreateerror', $dstDir ); + if ( !is_dir( $dstDir ) ) { + if ( !wfMkdirParents( $dstDir ) ) { + return $this->newFatal( 'directorycreateerror', $dstDir ); + } + // In the deleted zone, seed new directories with a blank + // index.html, to prevent crawling + if ( $dstZone == 'deleted' ) { + file_put_contents( "$dstDir/index.html", '' ); + } } if ( self::isVirtualUrl( $srcPath ) ) { @@ -375,9 +382,13 @@ class FSRepo extends FileRepo { } $archivePath = "{$this->deletedDir}/$archiveRel"; $archiveDir = dirname( $archivePath ); - if ( !wfMkdirParents( $archiveDir ) ) { - $status->fatal( 'directorycreateerror', $archiveDir ); - continue; + if ( !is_dir( $archiveDir ) ) { + if ( !wfMkdirParents( $archiveDir ) ) { + $status->fatal( 'directorycreateerror', $archiveDir ); + continue; + } + // Seed new directories with a blank index.html, to prevent crawling + file_put_contents( "$archiveDir/index.html", '' ); } // Check if the archive directory is writable // This doesn't appear to work on NTFS -- 2.20.1