Remove \OCP\Files::tmpFile

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-03-19 10:52:35 +01:00
parent 63bc633d89
commit 47a3008141
No known key found for this signature in database
GPG Key ID: F941078878347C0C
11 changed files with 11 additions and 24 deletions

View File

@ -410,7 +410,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} }
case 'w': case 'w':
case 'wb': case 'wb':
$tmpFile = \OCP\Files::tmpFile(); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
$handle = fopen($tmpFile, 'w'); $handle = fopen($tmpFile, 'w');
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
@ -431,7 +431,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
} else { } else {
$ext = ''; $ext = '';
} }
$tmpFile = \OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
if ($this->file_exists($path)) { if ($this->file_exists($path)) {
$source = $this->readObject($path); $source = $this->readObject($path);
file_put_contents($tmpFile, $source); file_put_contents($tmpFile, $source);

View File

@ -128,7 +128,7 @@ class FTP extends StreamWrapper{
} else { } else {
$ext=''; $ext='';
} }
$tmpFile=\OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
if ($this->file_exists($path)) { if ($this->file_exists($path)) {
$this->getFile($path, $tmpFile); $this->getFile($path, $tmpFile);
} }

View File

@ -353,7 +353,7 @@ class SMB extends Common implements INotifyStorage {
if (!$this->isCreatable(dirname($path))) { if (!$this->isCreatable(dirname($path))) {
return false; return false;
} }
$tmpFile = \OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
} }
$source = fopen($tmpFile, $mode); $source = fopen($tmpFile, $mode);
$share = $this->share; $share = $this->share;

View File

@ -428,7 +428,7 @@ class Swift extends \OC\Files\Storage\Common {
} else { } else {
$ext = ''; $ext = '';
} }
$tmpFile = \OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
// Fetch existing file if required // Fetch existing file if required
if ($mode[0] !== 'w' && $this->file_exists($path)) { if ($mode[0] !== 'w' && $this->file_exists($path)) {
if ($mode[0] === 'x') { if ($mode[0] === 'x') {

View File

@ -346,7 +346,7 @@ class TAR extends Archive {
} else { } else {
$ext = ''; $ext = '';
} }
$tmpFile = \OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
if ($this->fileExists($path)) { if ($this->fileExists($path)) {
$this->extractFile($path, $tmpFile); $this->extractFile($path, $tmpFile);
} elseif ($mode == 'r' or $mode == 'rb') { } elseif ($mode == 'r' or $mode == 'rb') {

View File

@ -198,7 +198,7 @@ class ZIP extends Archive{
}else{ }else{
$ext=''; $ext='';
} }
$tmpFile=\OCP\Files::tmpFile($ext); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
if($this->fileExists($path)) { if($this->fileExists($path)) {
$this->extractFile($path, $tmpFile); $this->extractFile($path, $tmpFile);
} }

View File

@ -206,7 +206,7 @@ abstract class Flysystem extends Common {
if (!$this->isCreatable(dirname($path))) { if (!$this->isCreatable(dirname($path))) {
return false; return false;
} }
$tmpFile = \OCP\Files::tmpFile(); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
} }
$source = fopen($tmpFile, $mode); $source = fopen($tmpFile, $mode);
return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath) { return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath) {

View File

@ -88,19 +88,6 @@ class Files {
return $count; return $count;
} }
/**
* Create a temporary file with an unique filename
* @param string $postfix
* @return string
*
* temporary files are automatically cleaned up after the script is finished
* @deprecated 8.1.0 use getTemporaryFile() of \OCP\ITempManager - \OC::$server->getTempManager()
* @since 5.0.0
*/
public static function tmpFile( $postfix='' ) {
return \OC::$server->getTempManager()->getTemporaryFile($postfix);
}
/** /**
* Create a temporary folder with an unique filename * Create a temporary folder with an unique filename
* @return string * @return string

View File

@ -18,6 +18,6 @@ class TARTest extends TestBase {
} }
protected function getNew() { protected function getNew() {
return new TAR(\OCP\Files::tmpFile('.tar.gz')); return new TAR(\OC::$server->getTempManager()->getTemporaryFile('.tar.gz'));
} }
} }

View File

@ -58,7 +58,7 @@ abstract class TestBase extends \Test\TestCase {
$textFile=$dir.'/lorem.txt'; $textFile=$dir.'/lorem.txt';
$this->assertEquals(file_get_contents($textFile), $this->instance->getFile('lorem.txt')); $this->assertEquals(file_get_contents($textFile), $this->instance->getFile('lorem.txt'));
$tmpFile=\OCP\Files::tmpFile('.txt'); $tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$this->instance->extractFile('lorem.txt', $tmpFile); $this->instance->extractFile('lorem.txt', $tmpFile);
$this->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile)); $this->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile));
} }

View File

@ -18,6 +18,6 @@ class ZIPTest extends TestBase {
} }
protected function getNew() { protected function getNew() {
return new ZIP(\OCP\Files::tmpFile('.zip')); return new ZIP(\OC::$server->getTempManager()->getTemporaryFile('.zip'));
} }
} }