* backends with virtual directories may not have this limitation. Callers should
* store files in such a way that no files and directories are under the same path.
*
- * Methods should avoid throwing exceptions at all costs.
+ * Methods of subclasses should avoid throwing exceptions at all costs.
* As a corollary, external dependencies should be kept to a minimum.
*
* @ingroup FileBackend
return $this->name;
}
+ /**
+ * Get the wiki identifier used for this backend (possibly empty).
+ * Note that this might *not* be in the same format as wfWikiID().
+ *
+ * @return string
+ * @since 1.20
+ */
+ final public function getWikiId() {
+ return $this->wikiId;
+ }
+
/**
* Check if this backend is read-only
*
unset( $opts['nonLocking'] );
unset( $opts['allowStale'] );
}
- $opts['concurrency'] = 1; // off
- if ( $this->parallelize === 'implicit' ) {
- if ( !isset( $opts['parallelize'] ) || $opts['parallelize'] ) {
- $opts['concurrency'] = $this->concurrency;
- }
- } elseif ( $this->parallelize === 'explicit' ) {
- if ( !empty( $opts['parallelize'] ) ) {
- $opts['concurrency'] = $this->concurrency;
- }
- }
return $this->doOperationsInternal( $ops, $opts );
}
/**
* Delete a storage directory if it is empty.
* Backends using key/value stores may do nothing unless the directory
- * is that of an empty container, in which case it should be deleted.
+ * is that of an empty container, in which case it will be deleted.
*
* @param $params Array
* $params include:
* - latest : use the latest available data
* @return string|bool Returns false on failure
*/
- abstract public function getFileContents( array $params );
+ final public function getFileContents( array $params ) {
+ $contents = $this->getFileContentsMulti(
+ array( 'srcs' => array( $params['src'] ) ) + $params );
+
+ return $contents[$params['src']];
+ }
+
+ /**
+ * Like getFileContents() except it takes an array of storage paths
+ * and returns a map of storage paths to strings (or null on failure).
+ * The map keys (paths) are in the same order as the provided list of paths.
+ *
+ * @see FileBackend::getFileContents()
+ *
+ * @param $params Array
+ * $params include:
+ * - srcs : list of source storage paths
+ * - latest : use the latest available data
+ * - parallelize : try to do operations in parallel when possible
+ * @return Array Map of (path name => string or false on failure)
+ * @since 1.20
+ */
+ abstract public function getFileContentsMulti( array $params );
/**
* Get the size (bytes) of a file at a storage path in the backend.
/**
* Stream the file at a storage path in the backend.
- * If the file does not exists, a 404 error will be given.
+ * If the file does not exists, an HTTP 404 error will be given.
* Appropriate HTTP headers (Status, Content-Type, Content-Length)
- * must be sent if streaming began, while none should be sent otherwise.
+ * will be sent if streaming began, while none will be sent otherwise.
* Implementations should flush the output buffer before sending data.
*
* @param $params Array
* $params include:
* - src : source storage path
- * - headers : additional HTTP headers to send on success
+ * - headers : list of additional HTTP headers to send on success
* - latest : use the latest available data
* @return Status
*/
* - latest : use the latest available data
* @return FSFile|null Returns null on failure
*/
- abstract public function getLocalReference( array $params );
+ final public function getLocalReference( array $params ) {
+ $fsFiles = $this->getLocalReferenceMulti(
+ array( 'srcs' => array( $params['src'] ) ) + $params );
+
+ return $fsFiles[$params['src']];
+ }
+
+ /**
+ * Like getLocalReference() except it takes an array of storage paths
+ * and returns a map of storage paths to FSFile objects (or null on failure).
+ * The map keys (paths) are in the same order as the provided list of paths.
+ *
+ * @see FileBackend::getLocalReference()
+ *
+ * @param $params Array
+ * $params include:
+ * - srcs : list of source storage paths
+ * - latest : use the latest available data
+ * - parallelize : try to do operations in parallel when possible
+ * @return Array Map of (path name => FSFile or null on failure)
+ * @since 1.20
+ */
+ abstract public function getLocalReferenceMulti( array $params );
/**
* Get a local copy on disk of the file at a storage path in the backend.
* - latest : use the latest available data
* @return TempFSFile|null Returns null on failure
*/
- abstract public function getLocalCopy( array $params );
+ final public function getLocalCopy( array $params ) {
+ $tmpFiles = $this->getLocalCopyMulti(
+ array( 'srcs' => array( $params['src'] ) ) + $params );
+
+ return $tmpFiles[$params['src']];
+ }
+
+ /**
+ * Like getLocalCopy() except it takes an array of storage paths and
+ * returns a map of storage paths to TempFSFile objects (or null on failure).
+ * The map keys (paths) are in the same order as the provided list of paths.
+ *
+ * @see FileBackend::getLocalCopy()
+ *
+ * @param $params Array
+ * $params include:
+ * - srcs : list of source storage paths
+ * - latest : use the latest available data
+ * - parallelize : try to do operations in parallel when possible
+ * @return Array Map of (path name => TempFSFile or null on failure)
+ * @since 1.20
+ */
+ abstract public function getLocalCopyMulti( array $params );
/**
* Check if a directory exists at a given storage path.
/**
* Get an iterator to list *all* directories under a storage directory.
* If the directory is of the form "mwstore://backend/container",
- * then all directories in the container should be listed.
+ * then all directories in the container will be listed.
* If the directory is of form "mwstore://backend/container/dir",
- * then all directories directly under that directory should be listed.
- * Results should be storage directories relative to the given directory.
+ * then all directories directly under that directory will be listed.
+ * Results will be storage directories relative to the given directory.
*
* Storage backends with eventual consistency might return stale data.
*
/**
* Get an iterator to list *all* stored files under a storage directory.
* If the directory is of the form "mwstore://backend/container",
- * then all files in the container should be listed.
+ * then all files in the container will be listed.
* If the directory is of form "mwstore://backend/container/dir",
- * then all files under that directory should be listed.
- * Results should be storage paths relative to the given directory.
+ * then all files under that directory will be listed.
+ * Results will be storage paths relative to the given directory.
*
* Storage backends with eventual consistency might return stale data.
*