Skip to content

Commit

Permalink
factor out hidden folder name into a seperate function
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Jan 11, 2022
1 parent 923a3eb commit 29e6fde
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
namespace OCA\DAV\Connector\Sabre;

use OC\Files\Filesystem;
use OC\Files\Mount\MoveableMount;
use OC\Files\View;
use OCA\DAV\Connector\Sabre\Exception\FileLocked;
Expand Down Expand Up @@ -266,7 +267,7 @@ public function getChildren() {
throw new Locked();
}

$hiddenName = 'hidden_' . \OC_Util::getInstanceId();
$hiddenName = Filesystem::getHiddenFolderName();

$nodes = [];
foreach ($folderContent as $info) {
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Cache/QuerySearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
namespace OC\Files\Cache;

use OC\Files\Filesystem;
use OC\Files\Search\QueryOptimizer\QueryOptimizer;
use OC\Files\Search\SearchBinaryOperator;
use OC\SystemConfig;
Expand Down Expand Up @@ -133,7 +134,7 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
}

// exclude entries from the hidden folder in the user storage
$query->andWhere($query->expr()->notLike('path', $query->createNamedParameter('files/hidden_' . \OC_Util::getInstanceId() . '%')));
$query->andWhere($query->expr()->notLike('path', $query->createNamedParameter('files/' . Filesystem::getHiddenFolderName() . '%')));

$this->searchBuilder->addSearchOrdersToQuery($query, $searchQuery->getOrder());

Expand Down
4 changes: 4 additions & 0 deletions lib/private/Files/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -897,4 +897,8 @@ public static function getOwner($path) {
public static function getETag($path) {
return self::$defaultInstance->getETag($path);
}

public static function getHiddenFolderName(): string {
return '.hidden_' . \OC_Util::getInstanceId();
}
}
3 changes: 2 additions & 1 deletion lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
namespace OC\Files\Node;

use OC\Files\Cache\QuerySearchHelper;
use OC\Files\Filesystem;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Search\SearchComparison;
Expand Down Expand Up @@ -256,7 +257,7 @@ public function search($query) {
$mountByMountPoint = ['' => $mount];

if (!$limitToHome) {
$hiddenFolder = 'hidden_' . \OC_Util::getInstanceId();
$hiddenFolder = Filesystem::getHiddenFolderName();
$mounts = $this->root->getMountsIn($this->path);
foreach ($mounts as $mount) {
// don't search in mounts inside the hidden folder
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
namespace OC\Files\Node;

use OC\Cache\CappedMemoryCache;
use OC\Files\Filesystem;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
use OC\Hooks\PublicEmitter;
Expand Down Expand Up @@ -395,7 +396,7 @@ public function getUserFolder($userId) {

public function getHiddenUserFolder($userId) {
$userFolder = $this->getUserFolder($userId);
$hiddenName = 'hidden_' . \OC_Util::getInstanceId();
$hiddenName = Filesystem::getHiddenFolderName();
try {
return $userFolder->get($hiddenName);
} catch (NotFoundException $e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,7 @@ private function searchCommon($method, $args) {
}
}

$hiddenFolder = 'hidden_' . \OC_Util::getInstanceId();
$hiddenFolder = Filesystem::getHiddenFolderName();
$mounts = Filesystem::getMountManager()->findIn($this->fakeRoot);
foreach ($mounts as $mount) {
$mountPoint = $mount->getMountPoint();
Expand Down

0 comments on commit 29e6fde

Please sign in to comment.