Merge pull request #26216 from nextcloud/backport/26145/stable19

[stable19] add (hidden) option to always show smb root as writable
This commit is contained in:
Roeland Jago Douma 2021-03-20 10:53:45 +01:00 committed by GitHub
commit 9b23da22c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -97,6 +97,9 @@ class SMB extends Common implements INotifyStorage {
/** @var bool */
protected $checkAcl;
/** @var bool */
protected $rootWritable;
public function __construct($params) {
if (!isset($params['host'])) {
throw new \Exception('Invalid configuration, no host provided');
@ -134,6 +137,7 @@ class SMB extends Common implements INotifyStorage {
$this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
$this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
$this->rootWritable = isset($params['root_force_writable']) && $params['root_force_writable'];
$this->statCache = new CappedMemoryCache();
parent::__construct($params);
@ -567,7 +571,11 @@ class SMB extends Common implements INotifyStorage {
private function getMetaDataFromFileInfo(IFileInfo $fileInfo) {
$permissions = Constants::PERMISSION_READ + Constants::PERMISSION_SHARE;
if (!$fileInfo->isReadOnly()) {
if (
!$fileInfo->isReadOnly() || (
$this->rootWritable && $fileInfo->getPath() == $this->buildPath('')
)
) {
$permissions += Constants::PERMISSION_DELETE;
$permissions += Constants::PERMISSION_UPDATE;
if ($fileInfo->isDirectory()) {