Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/files_external/lib/Lib/Storage/AmazonS3.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public function fopen($path, $mode) {
}
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) {
Expand All @@ -431,7 +431,7 @@ public function fopen($path, $mode) {
} 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);
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/FTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function fopen($path,$mode) {
} else {
$ext='';
}
$tmpFile=\OCP\Files::tmpFile($ext);
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
if ($this->file_exists($path)) {
$this->getFile($path, $tmpFile);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/SMB.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function fopen($path, $mode) {
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;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/lib/Lib/Storage/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public function fopen($path, $mode) {
} 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') {
Expand Down
8 changes: 4 additions & 4 deletions lib/private/Archive/TAR.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function addFile($path, $source = '') {
*/
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;
Expand Down Expand Up @@ -258,7 +258,7 @@ public function getFile($path) {
* @return bool
*/
public function extractFile($path, $dest) {
$tmp = \OCP\Files::tmpFolder();
$tmp = \OC::$server->getTempManager()->getTemporaryFolder();
if (!$this->fileExists($path)) {
return false;
}
Expand Down Expand Up @@ -323,7 +323,7 @@ public function remove($path) {
$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;
Expand All @@ -346,7 +346,7 @@ public function getStream($path, $mode) {
} 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') {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Archive/ZIP.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function getStream($path, $mode) {
}else{
$ext='';
}
$tmpFile=\OCP\Files::tmpFile($ext);
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
if($this->fileExists($path)) {
$this->extractFile($path, $tmpFile);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Storage/Flysystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function fopen($path, $mode) {
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) {
Expand Down
25 changes: 0 additions & 25 deletions lib/public/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,6 @@ public static function streamCopy( $source, $target ) {
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
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Archive/TARTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ protected function getExisting() {
}

protected function getNew() {
return new TAR(\OCP\Files::tmpFile('.tar.gz'));
return new TAR(\OC::$server->getTempManager()->getTemporaryFile('.tar.gz'));
}
}
4 changes: 2 additions & 2 deletions tests/lib/Archive/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testContent() {
$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));
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testFolder() {
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'));
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Archive/ZIPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ protected function getExisting() {
}

protected function getNew() {
return new ZIP(\OCP\Files::tmpFile('.zip'));
return new ZIP(\OC::$server->getTempManager()->getTemporaryFile('.zip'));
}
}
4 changes: 2 additions & 2 deletions tests/lib/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ public function testNeedUpgradeCore() {
}

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);
Expand Down