1
0
Fork 0

Only set file permissions when configured

This commit is contained in:
Michael 2021-03-13 11:37:11 +00:00
parent 60a74fd5dc
commit 0bc1ebe5bf
2 changed files with 10 additions and 5 deletions

View file

@ -127,13 +127,16 @@ class Proxy extends BaseModule
}
$basepath = $a->getBasePath();
$filepermission = DI::config()->get('system', 'proxy_file_chmod');
// Store original image
if ($direct_cache) {
// direct cache , store under ./proxy/
$filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true);
file_put_contents($filename, $image->asString());
chmod($filename, DI::config()->get('system', 'proxy_file_chmod'));
if (!empty($filepermission)) {
chmod($filename, $filepermission);
}
} elseif($cachefile !== '') {
// cache file
file_put_contents($cachefile, $image->asString());
@ -153,7 +156,9 @@ class Proxy extends BaseModule
if ($direct_cache && $request['sizetype'] != '') {
$filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype'];
file_put_contents($filename, $image->asString());
chmod($filename, DI::config()->get('system', 'proxy_file_chmod'));
if (!empty($filepermission)) {
chmod($filename, $filepermission);
}
}
self::responseImageHttpCache($image);

View file

@ -571,9 +571,9 @@ return [
// Timeout in seconds for fetching the XRD links.
'xrd_timeout' => 20,
// proxy_file_chmod (Integer)
// Access rights for downloaded files in /proxy/ directory
'proxy_file_chmod' => 0640,
// proxy_file_chmod (Octal Integer)
// Access rights for downloaded files in /proxy/ directory like 0640
'proxy_file_chmod' => 0,
],
'experimental' => [
// exp_themes (Boolean)