From: Aaron Date: Thu, 30 Aug 2012 23:03:36 +0000 (-0700) Subject: [FileRepo] Made temp zone files use doQuickOperations. X-Git-Tag: 1.31.0-rc.0~22513^2 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=01bb9a690fb24d8dd915d370a07199bcd9a4d70c;p=lhc%2Fweb%2Fwiklou.git [FileRepo] Made temp zone files use doQuickOperations. * This avoids stat and journaling overhead. Change-Id: I817e95fa15096bb02ab7505055949acd56164442 --- diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 3159077df1..bef2642f73 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -935,19 +935,38 @@ class FileRepo { public function storeTemp( $originalName, $srcPath ) { $this->assertWritableRepo(); // fail out if read-only - $date = gmdate( "YmdHis" ); - $hashPath = $this->getHashPath( $originalName ); - $dstRel = "{$hashPath}{$date}!{$originalName}"; - $dstUrlRel = $hashPath . $date . '!' . rawurlencode( $originalName ); + $date = gmdate( "YmdHis" ); + $hashPath = $this->getHashPath( $originalName ); + $dstRel = "{$hashPath}{$date}!{$originalName}"; + $dstUrlRel = $hashPath . $date . '!' . rawurlencode( $originalName ); + $virtualUrl = $this->getVirtualUrl( 'temp' ) . '/' . $dstUrlRel; - $result = $this->store( $srcPath, 'temp', $dstRel, self::SKIP_LOCKING ); - $result->value = $this->getVirtualUrl( 'temp' ) . '/' . $dstUrlRel; + $result = $this->quickImport( $srcPath, $virtualUrl ); + $result->value = $virtualUrl; return $result; } /** - * Concatenate a list of files into a target file location. + * Remove a temporary file or mark it for garbage collection + * + * @param $virtualUrl String: the virtual URL returned by FileRepo::storeTemp() + * @return Boolean: true on success, false on failure + */ + public function freeTemp( $virtualUrl ) { + $this->assertWritableRepo(); // fail out if read-only + + $temp = $this->getVirtualUrl( 'temp' ); + if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) { + wfDebug( __METHOD__.": Invalid temp virtual URL\n" ); + return false; + } + + return $this->quickPurge( $virtualUrl )->isOK(); + } + + /** + * Concatenate a list of temporary files into a target file location. * * @param $srcPaths Array Ordered list of source virtual URLs/storage paths * @param $dstPath String Target file system path @@ -961,14 +980,10 @@ class FileRepo { $status = $this->newGood(); $sources = array(); - $deleteOperations = array(); // post-concatenate ops foreach ( $srcPaths as $srcPath ) { // Resolve source to a storage path if virtual $source = $this->resolveToStoragePath( $srcPath ); $sources[] = $source; // chunk to merge - if ( $flags & self::DELETE_SOURCE ) { - $deleteOperations[] = array( 'op' => 'delete', 'src' => $source ); - } } // Concatenate the chunks into one FS file @@ -979,36 +994,16 @@ class FileRepo { } // Delete the sources if required - if ( $deleteOperations ) { - $opts = array( 'force' => true ); - $status->merge( $this->backend->doOperations( $deleteOperations, $opts ) ); + if ( $flags & self::DELETE_SOURCE ) { + $status->merge( $this->quickPurgeBatch( $srcPaths ) ); } - // Make sure status is OK, despite any $deleteOperations fatals + // Make sure status is OK, despite any quickPurgeBatch() fatals $status->setResult( true ); return $status; } - /** - * Remove a temporary file or mark it for garbage collection - * - * @param $virtualUrl String: the virtual URL returned by FileRepo::storeTemp() - * @return Boolean: true on success, false on failure - */ - public function freeTemp( $virtualUrl ) { - $this->assertWritableRepo(); // fail out if read-only - - $temp = "mwrepo://{$this->name}/temp"; - if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) { - wfDebug( __METHOD__.": Invalid temp virtual URL\n" ); - return false; - } - $path = $this->resolveVirtualUrl( $virtualUrl ); - - return $this->cleanupBatch( array( $path ), self::SKIP_LOCKING )->isOK(); - } - /** * Copy or move a file either from a storage path, virtual URL, * or FS path, into this repository at the specified destination location.