Merge pull request #8878 from nextcloud/remove_tmpfile
Remove deprecated tmpFile/tmpFolder
This commit is contained in:
commit
9834f33d56
|
@ -410,7 +410,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
|||
}
|
||||
case 'w':
|
||||
case 'wb':
|
||||
$tmpFile = \OCP\Files::tmpFile();
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
|
||||
$handle = fopen($tmpFile, 'w');
|
||||
return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) {
|
||||
|
@ -431,7 +431,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
|
|||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
$tmpFile = \OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
if ($this->file_exists($path)) {
|
||||
$source = $this->readObject($path);
|
||||
file_put_contents($tmpFile, $source);
|
||||
|
|
|
@ -128,7 +128,7 @@ class FTP extends StreamWrapper{
|
|||
} else {
|
||||
$ext='';
|
||||
}
|
||||
$tmpFile=\OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
if ($this->file_exists($path)) {
|
||||
$this->getFile($path, $tmpFile);
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ class SMB extends Common implements INotifyStorage {
|
|||
if (!$this->isCreatable(dirname($path))) {
|
||||
return false;
|
||||
}
|
||||
$tmpFile = \OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
}
|
||||
$source = fopen($tmpFile, $mode);
|
||||
$share = $this->share;
|
||||
|
|
|
@ -428,7 +428,7 @@ class Swift extends \OC\Files\Storage\Common {
|
|||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
$tmpFile = \OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
// Fetch existing file if required
|
||||
if ($mode[0] !== 'w' && $this->file_exists($path)) {
|
||||
if ($mode[0] === 'x') {
|
||||
|
|
|
@ -139,7 +139,7 @@ class TAR extends Archive {
|
|||
*/
|
||||
public function rename($source, $dest) {
|
||||
//no proper way to delete, rename entire archive, rename file and remake archive
|
||||
$tmp = \OCP\Files::tmpFolder();
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$this->tar->extract($tmp);
|
||||
rename($tmp . $source, $tmp . $dest);
|
||||
$this->tar = null;
|
||||
|
@ -258,7 +258,7 @@ class TAR extends Archive {
|
|||
* @return bool
|
||||
*/
|
||||
public function extractFile($path, $dest) {
|
||||
$tmp = \OCP\Files::tmpFolder();
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
if (!$this->fileExists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class TAR extends Archive {
|
|||
$this->fileList = false;
|
||||
$this->cachedHeaders = false;
|
||||
//no proper way to delete, extract entire archive, delete file and remake archive
|
||||
$tmp = \OCP\Files::tmpFolder();
|
||||
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$this->tar->extract($tmp);
|
||||
\OCP\Files::rmdirr($tmp . $path);
|
||||
$this->tar = null;
|
||||
|
@ -346,7 +346,7 @@ class TAR extends Archive {
|
|||
} else {
|
||||
$ext = '';
|
||||
}
|
||||
$tmpFile = \OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
if ($this->fileExists($path)) {
|
||||
$this->extractFile($path, $tmpFile);
|
||||
} elseif ($mode == 'r' or $mode == 'rb') {
|
||||
|
|
|
@ -198,7 +198,7 @@ class ZIP extends Archive{
|
|||
}else{
|
||||
$ext='';
|
||||
}
|
||||
$tmpFile=\OCP\Files::tmpFile($ext);
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
|
||||
if($this->fileExists($path)) {
|
||||
$this->extractFile($path, $tmpFile);
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ abstract class Flysystem extends Common {
|
|||
if (!$this->isCreatable(dirname($path))) {
|
||||
return false;
|
||||
}
|
||||
$tmpFile = \OCP\Files::tmpFile();
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
}
|
||||
$source = fopen($tmpFile, $mode);
|
||||
return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath) {
|
||||
|
|
|
@ -88,31 +88,6 @@ class Files {
|
|||
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
|
||||
* @return string
|
||||
*
|
||||
* temporary files are automatically cleaned up after the script is finished
|
||||
* @deprecated 8.1.0 use getTemporaryFolder() of \OCP\ITempManager - \OC::$server->getTempManager()
|
||||
* @since 5.0.0
|
||||
*/
|
||||
public static function tmpFolder() {
|
||||
return \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a suffix to the name in case the file exists
|
||||
* @param string $path
|
||||
|
|
|
@ -18,6 +18,6 @@ class TARTest extends TestBase {
|
|||
}
|
||||
|
||||
protected function getNew() {
|
||||
return new TAR(\OCP\Files::tmpFile('.tar.gz'));
|
||||
return new TAR(\OC::$server->getTempManager()->getTemporaryFile('.tar.gz'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ abstract class TestBase extends \Test\TestCase {
|
|||
$textFile=$dir.'/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->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile));
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ abstract class TestBase extends \Test\TestCase {
|
|||
public function testExtract() {
|
||||
$dir=\OC::$SERVERROOT.'/tests/data';
|
||||
$this->instance=$this->getExisting();
|
||||
$tmpDir=\OCP\Files::tmpFolder();
|
||||
$tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$this->instance->extract($tmpDir);
|
||||
$this->assertEquals(true, file_exists($tmpDir.'lorem.txt'));
|
||||
$this->assertEquals(true, file_exists($tmpDir.'dir/lorem.txt'));
|
||||
|
|
|
@ -18,6 +18,6 @@ class ZIPTest extends TestBase {
|
|||
}
|
||||
|
||||
protected function getNew() {
|
||||
return new ZIP(\OCP\Files::tmpFile('.zip'));
|
||||
return new ZIP(\OC::$server->getTempManager()->getTemporaryFile('.zip'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,13 +332,13 @@ class UtilTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testCheckDataDirectoryValidity() {
|
||||
$dataDir = \OCP\Files::tmpFolder();
|
||||
$dataDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
touch($dataDir . '/.ocdata');
|
||||
$errors = \OC_Util::checkDataDirectoryValidity($dataDir);
|
||||
$this->assertEmpty($errors);
|
||||
\OCP\Files::rmdirr($dataDir);
|
||||
|
||||
$dataDir = \OCP\Files::tmpFolder();
|
||||
$dataDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
// no touch
|
||||
$errors = \OC_Util::checkDataDirectoryValidity($dataDir);
|
||||
$this->assertNotEmpty($errors);
|
||||
|
|
Loading…
Reference in New Issue