Completed
Push — master ( 53eb0f...62e19d )
by Lukas
35:26 queued 21:10
created

LazyStorageMountInfo::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Robin Appelman <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OC\Files\Config;
24
25
use OC\Files\Filesystem;
26
use OCP\Files\Config\ICachedMountInfo;
27
use OCP\Files\Mount\IMountPoint;
28
use OCP\Files\Node;
29
use OCP\IUser;
30
31
class LazyStorageMountInfo extends CachedMountInfo {
32
	/** @var IMountPoint */
33
	private $mount;
34
35
	/**
36
	 * CachedMountInfo constructor.
37
	 *
38
	 * @param IUser $user
39
	 * @param IMountPoint $mount
40
	 */
41
	public function __construct(IUser $user, IMountPoint $mount) {
42
		$this->user = $user;
43
		$this->mount = $mount;
44
	}
45
46
	/**
47
	 * @return int the numeric storage id of the mount
48
	 */
49
	public function getStorageId() {
50
		if (!$this->storageId) {
51
			$this->storageId = $this->mount->getNumericStorageId();
52
		}
53
		return parent::getStorageId();
54
	}
55
56
	/**
57
	 * @return int the fileid of the root of the mount
58
	 */
59
	public function getRootId() {
60
		if (!$this->rootId) {
61
			$this->rootId = $this->mount->getStorageRootId();
62
		}
63
		return parent::getRootId();
64
	}
65
66
	/**
67
	 * @return string the mount point of the mount for the user
68
	 */
69
	public function getMountPoint() {
70
		if (!$this->mountPoint) {
71
			$this->mountPoint = $this->mount->getMountPoint();
72
		}
73
		return parent::getMountPoint();
74
	}
75
76
	public function getMountId() {
77
		return $this->mount->getMountId();
78
	}
79
80
	/**
81
	 * Get the internal path (within the storage) of the root of the mount
82
	 *
83
	 * @return string
84
	 */
85
	public function getRootInternalPath() {
86
		return $this->mount->getInternalPath($this->mount->getMountPoint());
87
	}
88
}
89