$this->trimCache(); // limit memory
$this->cache[$path]['stat'] = $stat;
$this->setFileCache( $path, $stat ); // update persistent cache
+ } else {
+ wfDebug( __METHOD__ . ": File $path does not exist.\n" );
}
wfProfileOut( __METHOD__ . '-' . $this->name );
wfProfileOut( __METHOD__ );
return $paths;
}
+ /**
+ * @see FileBackend::getScopedLocksForOps()
+ * @return Array
+ */
+ public function getScopedLocksForOps( array $ops, Status $status ) {
+ $paths = $this->getPathsToLockForOpsInternal( $this->getOperationsInternal( $ops ) );
+ return array(
+ $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status ),
+ $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status )
+ );
+ }
+
/**
* @see FileBackend::doOperationsInternal()
* @return Status
wfProfileIn( __METHOD__ . '-' . $this->name );
$status = Status::newGood();
- $async = $this->parallelize;
+ $supportedOps = array( 'create', 'store', 'copy', 'move', 'delete', 'null' );
+ $async = ( $this->parallelize === 'implicit' );
$maxConcurrency = $this->concurrency; // throttle
$statuses = array(); // array of (index => Status)
$curFileOpHandles = array(); // current handle batch
// Perform the sync-only ops and build up op handles for the async ops...
foreach ( $ops as $index => $params ) {
- $method = $params['op'] . 'Internal'; // e.g. "storeInternal"
- if ( !MWInit::methodExists( __CLASS__, $method ) ) {
+ if ( !in_array( $params['op'], $supportedOps ) ) {
wfProfileOut( __METHOD__ . '-' . $this->name );
wfProfileOut( __METHOD__ );
throw new MWException( "Operation '{$params['op']}' is not supported." );
}
+ $method = $params['op'] . 'Internal'; // e.g. "storeInternal"
$subStatus = $this->$method( array( 'async' => $async ) + $params );
if ( $subStatus->value instanceof FileBackendStoreOpHandle ) { // async
if ( count( $curFileOpHandles ) >= $maxConcurrency ) {
}
}
$res = $this->doExecuteOpHandlesInternal( $fileOpHandles );
+ foreach ( $fileOpHandles as $fileOpHandle ) {
+ $fileOpHandle->closeResources();
+ }
wfProfileOut( __METHOD__ . '-' . $this->name );
wfProfileOut( __METHOD__ );
return $res;
/**
* @see FileBackendStore::executeOpHandlesInternal()
* @return Array List of corresponding Status objects
- * @throws MWException
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
foreach ( $fileOpHandles as $fileOpHandle ) { // OK if empty
* Any empty suffix means the container is not sharded.
*
* @param $container string Container name
- * @param $relStoragePath string Storage path relative to the container
+ * @param $relPath string Storage path relative to the container
* @return string|null Returns null if shard could not be determined
*/
final protected function getContainerShard( $container, $relPath ) {
*
* @param $container string Resolved container name
* @param $val mixed Information to cache
- * @return void
*/
final protected function setContainerCache( $container, $val ) {
$this->memCache->set( $this->containerCacheKey( $container ), $val, 14*86400 );
/**
* Delete the cached info for a container
*
- * @param $containers string Resolved container name
- * @return void
+ * @param $container string Resolved container name
*/
final protected function deleteContainerCache( $container ) {
if ( !$this->memCache->delete( $this->containerCacheKey( $container ) ) ) {
*
* @param $path string Storage path
* @param $val mixed Information to cache
- * @return void
*/
final protected function setFileCache( $path, $val ) {
$this->memCache->set( $this->fileCacheKey( $path ), $val, 7*86400 );
* Delete the cached stat info for a file path
*
* @param $path string Storage path
- * @return void
*/
final protected function deleteFileCache( $path ) {
if ( !$this->memCache->delete( $this->fileCacheKey( $path ) ) ) {
* Iterator for listing directories
*/
class FileBackendStoreShardDirIterator extends FileBackendStoreShardListIterator {
+ /**
+ * @param string $container
+ * @param string $dir
+ * @param array $params
+ * @return Array|null|Traversable
+ */
protected function listFromShard( $container, $dir, array $params ) {
return $this->backend->getDirectoryListInternal( $container, $dir, $params );
}
* Iterator for listing regular files
*/
class FileBackendStoreShardFileIterator extends FileBackendStoreShardListIterator {
+ /**
+ * @param string $container
+ * @param string $dir
+ * @param array $params
+ * @return Array|null|Traversable
+ */
protected function listFromShard( $container, $dir, array $params ) {
return $this->backend->getFileListInternal( $container, $dir, $params );
}