Log unsuccessful temp file creation and return false

This commit is contained in:
Victor Dubiniuk 2014-07-29 18:18:15 +03:00 committed by Morris Jobke
parent 06d118d06c
commit 0113ad0b33
1 changed files with 14 additions and 2 deletions

View File

@ -578,8 +578,20 @@ class OC_Helper {
public static function tmpFile($postfix = '') {
$file = get_temp_dir() . '/' . md5(time() . rand()) . $postfix;
$fh = fopen($file, 'w');
fclose($fh);
self::$tmpFiles[] = $file;
if ($fh!==false){
fclose($fh);
self::$tmpFiles[] = $file;
} else {
OC_Log::write(
'OC_Helper',
sprintf(
'Can not create a temporary file in directory %s. Check it exists and has correct permissions',
get_temp_dir()
),
OC_Log::WARN
);
$file = false;
}
return $file;
}