Browse Source

Use TempManager instead of tmpFile

tags/v9.0beta1
Morris Jobke 8 years ago
parent
commit
a18c0983d5

+ 1
- 1
lib/private/files/objectstore/objectstorestorage.php View File

@@ -274,7 +274,7 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
} else {
$ext = '';
}
$tmpFile = \OC_Helper::tmpFile($ext);
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
\OC\Files\Stream\Close::registerCallback($tmpFile, array($this, 'writeBack'));
if ($this->file_exists($path)) {
$source = $this->fopen($path, 'r');

+ 1
- 1
lib/private/files/storage/localtempfiletrait.php View File

@@ -70,7 +70,7 @@ trait LocalTempFileTrait {
} else {
$extension = '';
}
$tmpFile = \OC_Helper::tmpFile($extension);
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension);
$target = fopen($tmpFile, 'w');
\OC_Helper::streamCopy($source, $target);
fclose($target);

+ 1
- 1
lib/private/files/type/detection.php View File

@@ -238,7 +238,7 @@ class Detection implements IMimeTypeDetector {
$finfo = finfo_open(FILEINFO_MIME);
return finfo_buffer($finfo, $data);
} else {
$tmpFile = \OC_Helper::tmpFile();
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
$fh = fopen($tmpFile, 'wb');
fwrite($fh, $data, 8024);
fclose($fh);

+ 1
- 1
lib/private/files/view.php View File

@@ -912,7 +912,7 @@ class View {
$source = $this->fopen($path, 'r');
if ($source) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
$tmpFile = \OC_Helper::tmpFile($extension);
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension);
file_put_contents($tmpFile, $source);
return $tmpFile;
} else {

+ 0
- 13
lib/private/helper.php View File

@@ -456,19 +456,6 @@ class OC_Helper {
return array($count, $result);
}

/**
* create a temporary file with an unique filename
*
* @param string $postfix
* @return string
* @deprecated Use the TempManager instead
*
* temporary files are automatically cleaned up after the script is finished
*/
public static function tmpFile($postfix = '') {
return \OC::$server->getTempManager()->getTemporaryFile($postfix);
}

/**
* Adds a suffix to the name in case the file exists
*

+ 1
- 1
lib/private/installer.php View File

@@ -264,7 +264,7 @@ class OC_Installer{
//download the file if necessary
if($data['source']=='http') {
$pathInfo = pathinfo($data['href']);
$path=OC_Helper::tmpFile('.' . $pathInfo['extension']);
$path = \OC::$server->getTempManager()->getTemporaryFile('.' . $pathInfo['extension']);
if(!isset($data['href'])) {
throw new \Exception($l->t("No href specified when installing app from http"));
}

+ 2
- 2
lib/private/preview/movie.php View File

@@ -46,7 +46,7 @@ class Movie extends Provider {
if ($useFileDirectly) {
$absPath = $fileview->getLocalFile($path);
} else {
$absPath = \OC_Helper::tmpFile();
$absPath = \OC::$server->getTempManager()->getTemporaryFile();

$handle = $fileview->fopen($path, 'rb');

@@ -79,7 +79,7 @@ class Movie extends Provider {
* @return bool|\OCP\IImage
*/
private function generateThumbNail($maxX, $maxY, $absPath, $second) {
$tmpPath = \OC_Helper::tmpFile();
$tmpPath = \OC::$server->getTempManager()->getTemporaryFile();

if (self::$avconvBinary) {
$cmd = self::$avconvBinary . ' -an -y -ss ' . escapeshellarg($second) .

+ 1
- 1
tests/lib/files/filesystem.php View File

@@ -302,7 +302,7 @@ class Filesystem extends \Test\TestCase {
\OC\Files\Filesystem::mkdir('/bar');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', 'foo');

$tmpFile = \OC_Helper::tmpFile();
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
// \OC\Files\Filesystem::file_put_contents('/bar//foo', $fh);

+ 3
- 3
tests/lib/installer.php View File

@@ -32,7 +32,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfTestApp .= '/../data/';
$pathOfTestApp .= 'testapp.zip';

$tmp = OC_Helper::tmpFile('.zip');
$tmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfTestApp, $tmp);

$data = array(
@@ -51,7 +51,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfOldTestApp .= '/../data/';
$pathOfOldTestApp .= 'testapp.zip';

$oldTmp = OC_Helper::tmpFile('.zip');
$oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);

$oldData = array(
@@ -63,7 +63,7 @@ class Test_Installer extends \Test\TestCase {
$pathOfNewTestApp .= '/../data/';
$pathOfNewTestApp .= 'testapp2.zip';

$newTmp = OC_Helper::tmpFile('.zip');
$newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfNewTestApp, $newTmp);

$newData = array(

+ 2
- 2
tests/lib/streamwrappers.php View File

@@ -55,7 +55,7 @@ class Test_StreamWrappers extends \Test\TestCase {
public function testCloseStream() {
//ensure all basic stream stuff works
$sourceFile = OC::$SERVERROOT . '/tests/data/lorem.txt';
$tmpFile = OC_Helper::TmpFile('.txt');
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$this->assertTrue(file_exists($file));
file_put_contents($file, file_get_contents($sourceFile));
@@ -65,7 +65,7 @@ class Test_StreamWrappers extends \Test\TestCase {
$this->assertFalse(file_exists($file));

//test callback
$tmpFile = OC_Helper::TmpFile('.txt');
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
$file = 'close://' . $tmpFile;
$actual = false;
$callback = function($path) use (&$actual) { $actual = $path; };

Loading…
Cancel
Save