Commit a18c0983 authored by Morris Jobke's avatar Morris Jobke
Browse files

Use TempManager instead of tmpFile

parent 90b0831c
......@@ -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');
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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
*
......
......@@ -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"));
}
......
......@@ -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) .
......
......@@ -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);
......
......@@ -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(
......
......@@ -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; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment