]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use TempManager instead of tmpFile
authorMorris Jobke <hey@morrisjobke.de>
Fri, 18 Dec 2015 10:25:33 +0000 (11:25 +0100)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 18 Dec 2015 10:25:33 +0000 (11:25 +0100)
lib/private/files/objectstore/objectstorestorage.php
lib/private/files/storage/localtempfiletrait.php
lib/private/files/type/detection.php
lib/private/files/view.php
lib/private/helper.php
lib/private/installer.php
lib/private/preview/movie.php
tests/lib/files/filesystem.php
tests/lib/installer.php
tests/lib/streamwrappers.php

index a053ea6d6d2ea75b0f67f805f8b5d6a89577d7d8..b34a6bdfb848754bc9a38c7539ebc4ea74733c2e 100644 (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');
index 84331f49b19fced5ac205db63b154f998ba47462..8875c2c4493038aaedd02d74ca151ab78996fa74 100644 (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);
index c102e739e0453d2b81c7c1615276f916f7782c43..0e2bab39e5bef50b10de1b3567b9231d316cbe6e 100644 (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);
index b8b1b8a50d6ea8ad8d962931831357c9277c988f..fcea4828c49af093ac5b9fe97de1876cbd56b996 100644 (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 {
index 556286f351949703ef28ef7eda35efc8395ecf64..08ddf2b0522b5d7aa652b80d180e55919d2c0038 100644 (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
         *
index c188f15718a2df7279d8afc7a3de037e988f8504..e1447db0db51593f18236da05649dbc950b5f5a0 100644 (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"));
                        }
index f71eaaf3eb2ba9e7af293e8005dee2f1bbe01349..2c2e6d0939916df007ef72f4539c4d396ab1cfc0 100644 (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) .
index 328ba5f44889c21e739a9f57fbcf851f5de4e621..db1f22f894ad9654b7ccd899b8ccf0bc006804e8 100644 (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);
index c3c2f8a275e838d8a0bcfeec9201d4448ae8fbb2..cfad4d7f0de5fea17faacddb604a94fdac88a555 100644 (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(
index 9b0975352807b10a4d7904b144b0f7edcfcbd7b1..7175683a60bcace9ab8101012b2e325d730d5021 100644 (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; };