summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorValerio Ponte <valerio.ponte@gmail.com>2013-05-10 21:11:47 +0200
committerValerio Ponte <valerio.ponte@gmail.com>2013-08-08 23:34:04 +0200
commit881e362f932bfd2d3b5daddd83545d09bda16e40 (patch)
tree8b7f849c0e056a99120584727327303fb256e0b9 /lib
parenta2ac5e016334429892ac84bafa2644d8d39e6eb2 (diff)
downloadnextcloud-server-881e362f932bfd2d3b5daddd83545d09bda16e40.tar.gz
nextcloud-server-881e362f932bfd2d3b5daddd83545d09bda16e40.zip
final fix for xsendfile zip generation race condition
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/helper.php b/lib/helper.php
index ca508e1d933..056c9a37fe5 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -621,9 +621,26 @@ class OC_Helper {
* remove all files in PHP /oc-noclean temp dir
*/
public static function cleanTmpNoClean() {
- $tmpDirNoCleanFile=get_temp_dir().'/oc-noclean/';
- if(file_exists($tmpDirNoCleanFile)) {
- self::rmdirr($tmpDirNoCleanFile);
+ $tmpDirNoCleanName=get_temp_dir().'/oc-noclean/';
+ if(file_exists($tmpDirNoCleanName) && is_dir($tmpDirNoCleanName)) {
+ $files=scandir($tmpDirNoCleanName);
+ foreach($files as $file) {
+ $fileName = $tmpDirNoCleanName . $file;
+ if (!\OC\Files\Filesystem::isIgnoredDir($file) && filemtime($fileName) + 600 < time()) {
+ unlink($fileName);
+ }
+ }
+ // if oc-noclean is empty delete it
+ $isTmpDirNoCleanEmpty = true;
+ $tmpDirNoClean = opendir($tmpDirNoCleanName);
+ while (false !== ($file = readdir($tmpDirNoClean))) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+ $isTmpDirNoCleanEmpty = false;
+ }
+ }
+ if ($isTmpDirNoCleanEmpty) {
+ rmdir($tmpDirNoCleanName);
+ }
}
}