Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit a7c4888

Browse files
committed
Added yii2tech\filestorage\local\Storage::$dirPermission
1 parent 0d8e66f commit a7c4888

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Yii 2 File Storage extension Change Log
22
=======================================
33

4+
1.1.4 under development
5+
-----------------------
6+
7+
- Enh #10: Added `yii2tech\filestorage\local\Storage::$dirPermission` allowing setup of directory permissions different from file permissions (klimov-paul)
8+
9+
410
1.1.3, November 3, 2017
511
-----------------------
612

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ return [
8484
'class' => 'yii2tech\filestorage\local\Storage',
8585
'basePath' => '@webroot/files',
8686
'baseUrl' => '@web/files',
87-
'filePermission' => 0777,
87+
'dirPermission' => 0775,
88+
'filePermission' => 0755,
8889
'buckets' => [
8990
'tempFiles' => [
9091
'baseSubPath' => 'temp',

local/Bucket.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ protected function resolveFullFileName($fileName)
149149
protected function resolvePath($path)
150150
{
151151
if (!file_exists($path)) {
152-
$dirPermission = $this->getStorage()->filePermission;
153152
$this->log("creating file path '{$path}'");
154-
FileHelper::createDirectory($path, $dirPermission);
153+
FileHelper::createDirectory($path, $this->getStorage()->dirPermission);
155154
}
156155
if (!is_dir($path)) {
157156
throw new Exception("Path '{$path}' is not a directory!");

local/Storage.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
* 'class' => 'yii2tech\filestorage\local\Storage',
2121
* 'basePath' => '@webroot/files',
2222
* 'baseUrl' => '@web/files',
23-
* 'filePermission' => 0777,
23+
* 'dirPermission' => 0775,
24+
* 'filePermission' => 0755,
2425
* 'buckets' => [
2526
* 'tempFiles' => [
2627
* 'baseSubPath' => 'temp',
@@ -53,12 +54,30 @@ class Storage extends BaseStorage
5354
* created in the process. Defaults to 0755 (owner rwx, group rx and others rx).
5455
*/
5556
public $filePermission = 0755;
57+
/**
58+
* @var int the chmod permission for the directories created in the process.
59+
* If not set - value of [[filePermission]] will be used.
60+
* @since 1.1.4
61+
*/
62+
public $dirPermission;
5663
/**
5764
* @var string file system path, which is basic for all buckets.
5865
*/
5966
private $_basePath = '';
6067

6168

69+
/**
70+
* {@inheritdoc}
71+
*/
72+
public function init()
73+
{
74+
parent::init();
75+
76+
if ($this->dirPermission === null) {
77+
$this->dirPermission = $this->filePermission;
78+
}
79+
}
80+
6281
/**
6382
* @param string $basePath file system path, which is basic for all buckets.
6483
*/

0 commit comments

Comments
 (0)