summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-05-03 05:37:01 -0700
committerBart Visscher <bartv@thisnet.nl>2013-05-03 05:37:01 -0700
commit05a0b4533b079b50f013bdf511b45a9f8dcb976d (patch)
tree228e8b67ef908e5bfe735727c55185dbccfbb440 /lib/helper.php
parent9c3b83e28c8a10f9ad38d3487dae1a3bc9601635 (diff)
parent033c94d076e3340a4a472d1b3f61ade5f22009ea (diff)
downloadnextcloud-server-05a0b4533b079b50f013bdf511b45a9f8dcb976d.tar.gz
nextcloud-server-05a0b4533b079b50f013bdf511b45a9f8dcb976d.zip
Merge pull request #2491 from riso/xsendfile_fix_zip
improved handling of xsendfile zip generation race condition
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 2ba70294f4b..c69445ed788 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -541,13 +541,15 @@ class OC_Helper {
}
/**
- * create a temporary file with an unique filename. It will not be deleted
- * automatically
- * @param string $postfix
- * @return string
+ * move a file to oc-noclean temp dir
+ * @param string $filename
+ * @return mixed
*
*/
- public static function tmpFileNoClean($postfix='') {
+ public static function moveToNoClean($filename='') {
+ if ($filename == '') {
+ return false;
+ }
$tmpDirNoClean=get_temp_dir().'/oc-noclean/';
if (!file_exists($tmpDirNoClean) || !is_dir($tmpDirNoClean)) {
if (file_exists($tmpDirNoClean)) {
@@ -555,10 +557,12 @@ class OC_Helper {
}
mkdir($tmpDirNoClean);
}
- $file=$tmpDirNoClean.md5(time().rand()).$postfix;
- $fh=fopen($file, 'w');
- fclose($fh);
- return $file;
+ $newname=$tmpDirNoClean.basename($filename);
+ if (rename($filename, $newname)) {
+ return $newname;
+ } else {
+ return false;
+ }
}
/**
@@ -597,7 +601,7 @@ class OC_Helper {
}
/**
- * remove all files created by self::tmpFileNoClean
+ * remove all files in PHP /oc-noclean temp dir
*/
public static function cleanTmpNoClean() {
$tmpDirNoCleanFile=get_temp_dir().'/oc-noclean/';