-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathCollectiveStorage.php
79 lines (68 loc) · 1.96 KB
/
CollectiveStorage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Collectives\Mount;
use OC\Files\Cache\Scanner;
use OC\Files\ObjectStore\NoopScanner;
use OC\Files\ObjectStore\ObjectStoreScanner;
use OC\Files\ObjectStore\ObjectStoreStorage;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Files\Cache\ICacheEntry;
use OCP\IUser;
class CollectiveStorage extends Wrapper {
private int $folderId;
private ICacheEntry $rootEntry;
private ?IUser $mountOwner;
/** @var RootEntryCache */
public $cache;
public function __construct($parameters) {
parent::__construct($parameters);
$this->folderId = $parameters['folder_id'];
$this->rootEntry = $parameters['rootCacheEntry'];
$this->mountOwner = $parameters['mountOwner'];
}
public function getFolderId(): int {
return $this->folderId;
}
/**
* @param string $path
*
* @return string|false
*/
public function getOwner($path): string|false {
return $this->mountOwner !== null ? $this->mountOwner->getUID() : false;
}
/**
* @param string $path
* @param null $storage
*/
public function getCache($path = '', $storage = null): RootEntryCache {
if ($this->cache) {
return $this->cache;
}
if (!$storage) {
$storage = $this;
}
$this->cache = new RootEntryCache(parent::getCache($path, $storage), $this->rootEntry);
return $this->cache;
}
/**
* @param string $path
* @param null $storage
*/
public function getScanner($path = '', $storage = null): Scanner {
if (!$storage) {
$storage = $this;
}
if ($storage->instanceOfStorage(ObjectStoreStorage::class)) {
// NoopScanner is private API and kept here for compatibility with older releases
$storage->scanner = class_exists(NoopScanner::class) ? new NoopScanner($storage) : new ObjectStoreScanner($storage);
} elseif (!isset($storage->scanner)) {
$storage->scanner = new Scanner($storage);
}
return $storage->scanner;
}
}