}
if ( !empty( $params['async'] ) ) { // deferred
- $tempFile = TempFSFile::factory( 'create_', 'tmp' );
+ $tempFile = TempFSFile::factory( 'create_', 'tmp', $this->tmpDirectory );
if ( !$tempFile ) {
$status->fatal( 'backend-fail-create', $params['dst'] );
} else {
// Create a new temporary file with the same extension...
$ext = FileBackend::extensionFromPath( $src );
- $tmpFile = TempFSFile::factory( 'localcopy_', $ext );
+ $tmpFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory );
if ( !$tmpFile ) {
$tmpFiles[$src] = null;
} else {
$config['wanCache'] = ObjectCache::getMainWANInstance();
$config['mimeCallback'] = [ $this, 'guessMimeInternal' ];
$config['statusWrapper'] = [ 'Status', 'wrap' ];
+ $config['tmpDirectory'] = wfTempDir();
$this->backends[$name]['instance'] = new $class( $config );
}
if ( !$type && $fsPath ) {
$type = $magic->guessMimeType( $fsPath, false );
} elseif ( !$type && strlen( $content ) ) {
- $tmpFile = TempFSFile::factory( 'mime_' );
+ $tmpFile = TempFSFile::factory( 'mime_', '', wfTempDir() );
file_put_contents( $tmpFile->getPath(), $content );
$type = $magic->guessMimeType( $tmpFile->getPath(), false );
}
} else {
// Create a new temporary file with the same extension...
$ext = FileBackend::extensionFromPath( $src );
- $fsFile = TempFSFile::factory( 'localcopy_', $ext );
+ $fsFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory );
if ( $fsFile ) {
$bytes = file_put_contents( $fsFile->getPath(), $this->files[$src]['data'] );
if ( $bytes !== strlen( $this->files[$src]['data'] ) ) {
// Get source file extension
$ext = FileBackend::extensionFromPath( $path );
// Create a new temporary file...
- $tmpFile = TempFSFile::factory( 'localcopy_', $ext );
+ $tmpFile = TempFSFile::factory( 'localcopy_', $ext, $this->tmpDirectory );
if ( $tmpFile ) {
$handle = fopen( $tmpFile->getPath(), 'wb' );
if ( $handle ) {
"{$repoName}-deleted" => $deletedDir
],
'fileMode' => $fileMode,
+ 'tmpDirectory' => wfTempDir()
] );
// Update repo config to use this backend
$info['backend'] = $backend;
/** @var int How many operations can be done in parallel */
protected $concurrency;
+ /** @var string Temporary file directory */
+ protected $tmpDirectory;
+
/** @var LockManager */
protected $lockManager;
* - parallelize : When to do file operations in parallel (when possible).
* Allowed values are "implicit", "explicit" and "off".
* - concurrency : How many file operations can be done in parallel.
+ * - tmpDirectory : Directory to use for temporary files. If this is not set or null,
+ * then the backend will try to discover a usable temporary directory.
* @throws FileBackendException
*/
public function __construct( array $config ) {
? (int)$config['concurrency']
: 50;
$this->statusWrapper = isset( $config['statusWrapper'] ) ? $config['statusWrapper'] : null;
+ $this->tmpDirectory = isset( $config['tmpDirectory'] ) ? $config['tmpDirectory'] : null;
}
/**