Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Nov 25, 2022
1 parent 6d19c3a commit 7927445
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ public function getChildren() {
throw new Locked();
}

$hiddenName = Filesystem::getHiddenFolderName();
$hiddenFolderName = Filesystem::getHiddenFolderName();

$nodes = [];
foreach ($folderContent as $info) {
if ($info->getName() !== $hiddenName) {
if ($info->getName() !== $hiddenFolderName) {
$node = $this->getChild($info->getName(), $info);
$nodes[] = $node;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Files/HiddenFolderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
use Sabre\DAV\ServerPlugin;

class HiddenFolderPlugin extends ServerPlugin {
public function initialize(Server $server) {
public function initialize(Server $server): void {
$server->on('beforeBind', [$this, 'onBind'], 1000);
$server->on('beforeUnbind', [$this, 'onBind'], 1000);
}

public function onBind($path) {
public function onBind($path): bool {
$hiddenName = Filesystem::getHiddenFolderName();
if (basename($path) === $hiddenName) {
throw new Forbidden("Can't modify hidden base folder");
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ public static function getHiddenFolderName(): string {
return '.hidden_' . \OC_Util::getInstanceId();
}

public static function isPathHidden($path): string {
public static function isPathHidden($path): bool {
return strpos($path, self::getHiddenFolderName()) !== false;
}
}
3 changes: 1 addition & 2 deletions lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,10 @@ public function search($query) {
$mountByMountPoint = ['' => $mount];

if (!$limitToHome) {
$hiddenFolder = Filesystem::getHiddenFolderName();
$mounts = $this->root->getMountsIn($this->path);
foreach ($mounts as $mount) {
// don't search in mounts inside the hidden folder
if (strpos($mount->getMountPoint(), '/' . $hiddenFolder .'/') !== false) {
if (Filesystem::isPathHidden($mount->getMountPoint())) {
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,11 @@ public function getUserFolder($userId) {

public function getHiddenUserFolder($userId) {
$userFolder = $this->getUserFolder($userId);
$hiddenName = Filesystem::getHiddenFolderName();
$hiddenFolderName = Filesystem::getHiddenFolderName();
try {
return $userFolder->get($hiddenName);
return $userFolder->get($hiddenFolderName);
} catch (NotFoundException $e) {
return $userFolder->newFolder($hiddenName);
return $userFolder->newFolder($hiddenFolderName);
}
}

Expand Down
3 changes: 1 addition & 2 deletions lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1666,13 +1666,12 @@ private function searchCommon($method, $args) {
}
}

$hiddenFolder = Filesystem::getHiddenFolderName();
$mounts = Filesystem::getMountManager()->findIn($this->fakeRoot);
foreach ($mounts as $mount) {
$mountPoint = $mount->getMountPoint();

// don't search in mounts inside the hidden folder
if (strpos($mountPoint, '/' . $hiddenFolder .'/') !== false) {
if (Filesystem::isPathHidden($mountPoint)) {
continue;
}

Expand Down

0 comments on commit 7927445

Please sign in to comment.