Passed
Push — master ( e58344...db2aea )
by Roeland
15:30 queued 12s
created
lib/private/Template/ResourceNotFoundException.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@
 block discarded – undo
24 24
 namespace OC\Template;
25 25
 
26 26
 class ResourceNotFoundException extends \LogicException {
27
-	protected $resource;
28
-	protected $webPath;
27
+    protected $resource;
28
+    protected $webPath;
29 29
 
30
-	/**
31
-	 * @param string $resource
32
-	 * @param string $webPath
33
-	 */
34
-	public function __construct($resource, $webPath) {
35
-		parent::__construct('Resource not found');
36
-		$this->resource = $resource;
37
-		$this->webPath = $webPath;
38
-	}
30
+    /**
31
+     * @param string $resource
32
+     * @param string $webPath
33
+     */
34
+    public function __construct($resource, $webPath) {
35
+        parent::__construct('Resource not found');
36
+        $this->resource = $resource;
37
+        $this->webPath = $webPath;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getResourcePath() {
44
+        return $this->webPath . '/' . $this->resource;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,6 +41,6 @@
 block discarded – undo
41 41
 	 * @return string
42 42
 	 */
43 43
 	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
44
+		return $this->webPath.'/'.$this->resource;
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/Legacy/RegularJob.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
 use OCP\AutoloadNotAllowedException;
27 27
 
28 28
 class RegularJob extends \OC\BackgroundJob\Job {
29
-	public function run($argument) {
30
-		try {
31
-			if (is_callable($argument)) {
32
-				call_user_func($argument);
33
-			}
34
-		} catch (AutoloadNotAllowedException $e) {
35
-			// job is from a disabled app, ignore
36
-			return null;
37
-		}
38
-	}
29
+    public function run($argument) {
30
+        try {
31
+            if (is_callable($argument)) {
32
+                call_user_func($argument);
33
+            }
34
+        } catch (AutoloadNotAllowedException $e) {
35
+            // job is from a disabled app, ignore
36
+            return null;
37
+        }
38
+    }
39 39
 }
Please login to merge, or discard this patch.
lib/private/Settings/Section.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -26,67 +26,67 @@
 block discarded – undo
26 26
 use OCP\Settings\IIconSection;
27 27
 
28 28
 class Section implements IIconSection {
29
-	/** @var string */
30
-	private $id;
31
-	/** @var string */
32
-	private $name;
33
-	/** @var int */
34
-	private $priority;
35
-	/** @var string */
36
-	private $icon;
29
+    /** @var string */
30
+    private $id;
31
+    /** @var string */
32
+    private $name;
33
+    /** @var int */
34
+    private $priority;
35
+    /** @var string */
36
+    private $icon;
37 37
 
38
-	/**
39
-	 * @param string $id
40
-	 * @param string $name
41
-	 * @param int $priority
42
-	 * @param string $icon
43
-	 */
44
-	public function __construct($id, $name, $priority, $icon = '') {
45
-		$this->id = $id;
46
-		$this->name = $name;
47
-		$this->priority = $priority;
48
-		$this->icon = $icon;
49
-	}
38
+    /**
39
+     * @param string $id
40
+     * @param string $name
41
+     * @param int $priority
42
+     * @param string $icon
43
+     */
44
+    public function __construct($id, $name, $priority, $icon = '') {
45
+        $this->id = $id;
46
+        $this->name = $name;
47
+        $this->priority = $priority;
48
+        $this->icon = $icon;
49
+    }
50 50
 
51
-	/**
52
-	 * returns the ID of the section. It is supposed to be a lower case string,
53
-	 * e.g. 'ldap'
54
-	 *
55
-	 * @returns string
56
-	 */
57
-	public function getID() {
58
-		return $this->id;
59
-	}
51
+    /**
52
+     * returns the ID of the section. It is supposed to be a lower case string,
53
+     * e.g. 'ldap'
54
+     *
55
+     * @returns string
56
+     */
57
+    public function getID() {
58
+        return $this->id;
59
+    }
60 60
 
61
-	/**
62
-	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
63
-	 * integration'. Use the L10N service to translate it.
64
-	 *
65
-	 * @return string
66
-	 */
67
-	public function getName() {
68
-		return $this->name;
69
-	}
61
+    /**
62
+     * returns the translated name as it should be displayed, e.g. 'LDAP / AD
63
+     * integration'. Use the L10N service to translate it.
64
+     *
65
+     * @return string
66
+     */
67
+    public function getName() {
68
+        return $this->name;
69
+    }
70 70
 
71
-	/**
72
-	 * @return int whether the form should be rather on the top or bottom of
73
-	 * the settings navigation. The sections are arranged in ascending order of
74
-	 * the priority values. It is required to return a value between 0 and 99.
75
-	 *
76
-	 * E.g.: 70
77
-	 */
78
-	public function getPriority() {
79
-		return $this->priority;
80
-	}
71
+    /**
72
+     * @return int whether the form should be rather on the top or bottom of
73
+     * the settings navigation. The sections are arranged in ascending order of
74
+     * the priority values. It is required to return a value between 0 and 99.
75
+     *
76
+     * E.g.: 70
77
+     */
78
+    public function getPriority() {
79
+        return $this->priority;
80
+    }
81 81
 
82
-	/**
83
-	 * returns the relative path to an 16*16 icon describing the section.
84
-	 * e.g. '/core/img/places/files.svg'
85
-	 *
86
-	 * @returns string
87
-	 * @since 12
88
-	 */
89
-	public function getIcon() {
90
-		return $this->icon;
91
-	}
82
+    /**
83
+     * returns the relative path to an 16*16 icon describing the section.
84
+     * e.g. '/core/img/places/files.svg'
85
+     *
86
+     * @returns string
87
+     * @since 12
88
+     */
89
+    public function getIcon() {
90
+        return $this->icon;
91
+    }
92 92
 }
Please login to merge, or discard this patch.
lib/private/Memcache/CASTrait.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -23,35 +23,35 @@
 block discarded – undo
23 23
 namespace OC\Memcache;
24 24
 
25 25
 trait CASTrait {
26
-	abstract public function get($key);
26
+    abstract public function get($key);
27 27
 
28
-	abstract public function set($key, $value, $ttl = 0);
28
+    abstract public function set($key, $value, $ttl = 0);
29 29
 
30
-	abstract public function remove($key);
30
+    abstract public function remove($key);
31 31
 
32
-	abstract public function add($key, $value, $ttl = 0);
32
+    abstract public function add($key, $value, $ttl = 0);
33 33
 
34
-	/**
35
-	 * Compare and set
36
-	 *
37
-	 * @param string $key
38
-	 * @param mixed $old
39
-	 * @param mixed $new
40
-	 * @return bool
41
-	 */
42
-	public function cas($key, $old, $new) {
43
-		//no native cas, emulate with locking
44
-		if ($this->add($key . '_lock', true)) {
45
-			if ($this->get($key) === $old) {
46
-				$this->set($key, $new);
47
-				$this->remove($key . '_lock');
48
-				return true;
49
-			} else {
50
-				$this->remove($key . '_lock');
51
-				return false;
52
-			}
53
-		} else {
54
-			return false;
55
-		}
56
-	}
34
+    /**
35
+     * Compare and set
36
+     *
37
+     * @param string $key
38
+     * @param mixed $old
39
+     * @param mixed $new
40
+     * @return bool
41
+     */
42
+    public function cas($key, $old, $new) {
43
+        //no native cas, emulate with locking
44
+        if ($this->add($key . '_lock', true)) {
45
+            if ($this->get($key) === $old) {
46
+                $this->set($key, $new);
47
+                $this->remove($key . '_lock');
48
+                return true;
49
+            } else {
50
+                $this->remove($key . '_lock');
51
+                return false;
52
+            }
53
+        } else {
54
+            return false;
55
+        }
56
+    }
57 57
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@
 block discarded – undo
41 41
 	 */
42 42
 	public function cas($key, $old, $new) {
43 43
 		//no native cas, emulate with locking
44
-		if ($this->add($key . '_lock', true)) {
44
+		if ($this->add($key.'_lock', true)) {
45 45
 			if ($this->get($key) === $old) {
46 46
 				$this->set($key, $new);
47
-				$this->remove($key . '_lock');
47
+				$this->remove($key.'_lock');
48 48
 				return true;
49 49
 			} else {
50
-				$this->remove($key . '_lock');
50
+				$this->remove($key.'_lock');
51 51
 				return false;
52 52
 			}
53 53
 		} else {
Please login to merge, or discard this patch.
lib/private/Memcache/Cache.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -26,72 +26,72 @@
 block discarded – undo
26 26
 namespace OC\Memcache;
27 27
 
28 28
 abstract class Cache implements \ArrayAccess, \OCP\ICache {
29
-	/**
30
-	 * @var string $prefix
31
-	 */
32
-	protected $prefix;
29
+    /**
30
+     * @var string $prefix
31
+     */
32
+    protected $prefix;
33 33
 
34
-	/**
35
-	 * @param string $prefix
36
-	 */
37
-	public function __construct($prefix = '') {
38
-		$this->prefix = $prefix;
39
-	}
34
+    /**
35
+     * @param string $prefix
36
+     */
37
+    public function __construct($prefix = '') {
38
+        $this->prefix = $prefix;
39
+    }
40 40
 
41
-	/**
42
-	 * @return string Prefix used for caching purposes
43
-	 */
44
-	public function getPrefix() {
45
-		return $this->prefix;
46
-	}
41
+    /**
42
+     * @return string Prefix used for caching purposes
43
+     */
44
+    public function getPrefix() {
45
+        return $this->prefix;
46
+    }
47 47
 
48
-	/**
49
-	 * @param string $key
50
-	 * @return mixed
51
-	 */
52
-	abstract public function get($key);
48
+    /**
49
+     * @param string $key
50
+     * @return mixed
51
+     */
52
+    abstract public function get($key);
53 53
 
54
-	/**
55
-	 * @param string $key
56
-	 * @param mixed $value
57
-	 * @param int $ttl
58
-	 * @return mixed
59
-	 */
60
-	abstract public function set($key, $value, $ttl = 0);
54
+    /**
55
+     * @param string $key
56
+     * @param mixed $value
57
+     * @param int $ttl
58
+     * @return mixed
59
+     */
60
+    abstract public function set($key, $value, $ttl = 0);
61 61
 
62
-	/**
63
-	 * @param string $key
64
-	 * @return mixed
65
-	 */
66
-	abstract public function hasKey($key);
62
+    /**
63
+     * @param string $key
64
+     * @return mixed
65
+     */
66
+    abstract public function hasKey($key);
67 67
 
68
-	/**
69
-	 * @param string $key
70
-	 * @return mixed
71
-	 */
72
-	abstract public function remove($key);
68
+    /**
69
+     * @param string $key
70
+     * @return mixed
71
+     */
72
+    abstract public function remove($key);
73 73
 
74
-	/**
75
-	 * @param string $prefix
76
-	 * @return mixed
77
-	 */
78
-	abstract public function clear($prefix = '');
74
+    /**
75
+     * @param string $prefix
76
+     * @return mixed
77
+     */
78
+    abstract public function clear($prefix = '');
79 79
 
80
-	//implement the ArrayAccess interface
80
+    //implement the ArrayAccess interface
81 81
 
82
-	public function offsetExists($offset) {
83
-		return $this->hasKey($offset);
84
-	}
82
+    public function offsetExists($offset) {
83
+        return $this->hasKey($offset);
84
+    }
85 85
 
86
-	public function offsetSet($offset, $value) {
87
-		$this->set($offset, $value);
88
-	}
86
+    public function offsetSet($offset, $value) {
87
+        $this->set($offset, $value);
88
+    }
89 89
 
90
-	public function offsetGet($offset) {
91
-		return $this->get($offset);
92
-	}
90
+    public function offsetGet($offset) {
91
+        return $this->get($offset);
92
+    }
93 93
 
94
-	public function offsetUnset($offset) {
95
-		$this->remove($offset);
96
-	}
94
+    public function offsetUnset($offset) {
95
+        $this->remove($offset);
96
+    }
97 97
 }
Please login to merge, or discard this patch.
lib/private/Memcache/CADTrait.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -23,32 +23,32 @@
 block discarded – undo
23 23
 namespace OC\Memcache;
24 24
 
25 25
 trait CADTrait {
26
-	abstract public function get($key);
26
+    abstract public function get($key);
27 27
 
28
-	abstract public function remove($key);
28
+    abstract public function remove($key);
29 29
 
30
-	abstract public function add($key, $value, $ttl = 0);
30
+    abstract public function add($key, $value, $ttl = 0);
31 31
 
32
-	/**
33
-	 * Compare and delete
34
-	 *
35
-	 * @param string $key
36
-	 * @param mixed $old
37
-	 * @return bool
38
-	 */
39
-	public function cad($key, $old) {
40
-		//no native cas, emulate with locking
41
-		if ($this->add($key . '_lock', true)) {
42
-			if ($this->get($key) === $old) {
43
-				$this->remove($key);
44
-				$this->remove($key . '_lock');
45
-				return true;
46
-			} else {
47
-				$this->remove($key . '_lock');
48
-				return false;
49
-			}
50
-		} else {
51
-			return false;
52
-		}
53
-	}
32
+    /**
33
+     * Compare and delete
34
+     *
35
+     * @param string $key
36
+     * @param mixed $old
37
+     * @return bool
38
+     */
39
+    public function cad($key, $old) {
40
+        //no native cas, emulate with locking
41
+        if ($this->add($key . '_lock', true)) {
42
+            if ($this->get($key) === $old) {
43
+                $this->remove($key);
44
+                $this->remove($key . '_lock');
45
+                return true;
46
+            } else {
47
+                $this->remove($key . '_lock');
48
+                return false;
49
+            }
50
+        } else {
51
+            return false;
52
+        }
53
+    }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,13 +38,13 @@
 block discarded – undo
38 38
 	 */
39 39
 	public function cad($key, $old) {
40 40
 		//no native cas, emulate with locking
41
-		if ($this->add($key . '_lock', true)) {
41
+		if ($this->add($key.'_lock', true)) {
42 42
 			if ($this->get($key) === $old) {
43 43
 				$this->remove($key);
44
-				$this->remove($key . '_lock');
44
+				$this->remove($key.'_lock');
45 45
 				return true;
46 46
 			} else {
47
-				$this->remove($key . '_lock');
47
+				$this->remove($key.'_lock');
48 48
 				return false;
49 49
 			}
50 50
 		} else {
Please login to merge, or discard this patch.
lib/private/OCS/CoreCapabilities.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -33,27 +33,27 @@
 block discarded – undo
33 33
  */
34 34
 class CoreCapabilities implements ICapability {
35 35
 
36
-	/** @var IConfig */
37
-	private $config;
36
+    /** @var IConfig */
37
+    private $config;
38 38
 
39
-	/**
40
-	 * @param IConfig $config
41
-	 */
42
-	public function __construct(IConfig $config) {
43
-		$this->config = $config;
44
-	}
39
+    /**
40
+     * @param IConfig $config
41
+     */
42
+    public function __construct(IConfig $config) {
43
+        $this->config = $config;
44
+    }
45 45
 
46
-	/**
47
-	 * Return this classes capabilities
48
-	 *
49
-	 * @return array
50
-	 */
51
-	public function getCapabilities() {
52
-		return [
53
-			'core' => [
54
-				'pollinterval' => $this->config->getSystemValue('pollinterval', 60),
55
-				'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'),
56
-			]
57
-		];
58
-	}
46
+    /**
47
+     * Return this classes capabilities
48
+     *
49
+     * @return array
50
+     */
51
+    public function getCapabilities() {
52
+        return [
53
+            'core' => [
54
+                'pollinterval' => $this->config->getSystemValue('pollinterval', 60),
55
+                'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'),
56
+            ]
57
+        ];
58
+    }
59 59
 }
Please login to merge, or discard this patch.
lib/private/Files/Node/Root.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -372,12 +372,12 @@
 block discarded – undo
372 372
 			\OC\Files\Filesystem::initMountPoints($userId);
373 373
 
374 374
 			try {
375
-				$folder = $this->get('/' . $userId . '/files');
375
+				$folder = $this->get('/'.$userId.'/files');
376 376
 			} catch (NotFoundException $e) {
377
-				if (!$this->nodeExists('/' . $userId)) {
378
-					$this->newFolder('/' . $userId);
377
+				if (!$this->nodeExists('/'.$userId)) {
378
+					$this->newFolder('/'.$userId);
379 379
 				}
380
-				$folder = $this->newFolder('/' . $userId . '/files');
380
+				$folder = $this->newFolder('/'.$userId.'/files');
381 381
 			}
382 382
 
383 383
 			$this->userFolderCache->set($userId, $folder);
Please login to merge, or discard this patch.
Indentation   +336 added lines, -336 removed lines patch added patch discarded remove patch
@@ -64,340 +64,340 @@
 block discarded – undo
64 64
  * @package OC\Files\Node
65 65
  */
66 66
 class Root extends Folder implements IRootFolder {
67
-	/** @var Manager */
68
-	private $mountManager;
69
-	/** @var PublicEmitter */
70
-	private $emitter;
71
-	/** @var null|\OC\User\User */
72
-	private $user;
73
-	/** @var CappedMemoryCache */
74
-	private $userFolderCache;
75
-	/** @var IUserMountCache */
76
-	private $userMountCache;
77
-	/** @var ILogger */
78
-	private $logger;
79
-	/** @var IUserManager */
80
-	private $userManager;
81
-
82
-	/**
83
-	 * @param \OC\Files\Mount\Manager $manager
84
-	 * @param \OC\Files\View $view
85
-	 * @param \OC\User\User|null $user
86
-	 * @param IUserMountCache $userMountCache
87
-	 * @param ILogger $logger
88
-	 * @param IUserManager $userManager
89
-	 */
90
-	public function __construct($manager,
91
-								$view,
92
-								$user,
93
-								IUserMountCache $userMountCache,
94
-								ILogger $logger,
95
-								IUserManager $userManager) {
96
-		parent::__construct($this, $view, '');
97
-		$this->mountManager = $manager;
98
-		$this->user = $user;
99
-		$this->emitter = new PublicEmitter();
100
-		$this->userFolderCache = new CappedMemoryCache();
101
-		$this->userMountCache = $userMountCache;
102
-		$this->logger = $logger;
103
-		$this->userManager = $userManager;
104
-	}
105
-
106
-	/**
107
-	 * Get the user for which the filesystem is setup
108
-	 *
109
-	 * @return \OC\User\User
110
-	 */
111
-	public function getUser() {
112
-		return $this->user;
113
-	}
114
-
115
-	/**
116
-	 * @param string $scope
117
-	 * @param string $method
118
-	 * @param callable $callback
119
-	 */
120
-	public function listen($scope, $method, callable $callback) {
121
-		$this->emitter->listen($scope, $method, $callback);
122
-	}
123
-
124
-	/**
125
-	 * @param string $scope optional
126
-	 * @param string $method optional
127
-	 * @param callable $callback optional
128
-	 */
129
-	public function removeListener($scope = null, $method = null, callable $callback = null) {
130
-		$this->emitter->removeListener($scope, $method, $callback);
131
-	}
132
-
133
-	/**
134
-	 * @param string $scope
135
-	 * @param string $method
136
-	 * @param Node[] $arguments
137
-	 */
138
-	public function emit($scope, $method, $arguments = []) {
139
-		$this->emitter->emit($scope, $method, $arguments);
140
-	}
141
-
142
-	/**
143
-	 * @param \OC\Files\Storage\Storage $storage
144
-	 * @param string $mountPoint
145
-	 * @param array $arguments
146
-	 */
147
-	public function mount($storage, $mountPoint, $arguments = []) {
148
-		$mount = new MountPoint($storage, $mountPoint, $arguments);
149
-		$this->mountManager->addMount($mount);
150
-	}
151
-
152
-	/**
153
-	 * @param string $mountPoint
154
-	 * @return \OC\Files\Mount\MountPoint
155
-	 */
156
-	public function getMount($mountPoint) {
157
-		return $this->mountManager->find($mountPoint);
158
-	}
159
-
160
-	/**
161
-	 * @param string $mountPoint
162
-	 * @return \OC\Files\Mount\MountPoint[]
163
-	 */
164
-	public function getMountsIn($mountPoint) {
165
-		return $this->mountManager->findIn($mountPoint);
166
-	}
167
-
168
-	/**
169
-	 * @param string $storageId
170
-	 * @return \OC\Files\Mount\MountPoint[]
171
-	 */
172
-	public function getMountByStorageId($storageId) {
173
-		return $this->mountManager->findByStorageId($storageId);
174
-	}
175
-
176
-	/**
177
-	 * @param int $numericId
178
-	 * @return MountPoint[]
179
-	 */
180
-	public function getMountByNumericStorageId($numericId) {
181
-		return $this->mountManager->findByNumericId($numericId);
182
-	}
183
-
184
-	/**
185
-	 * @param \OC\Files\Mount\MountPoint $mount
186
-	 */
187
-	public function unMount($mount) {
188
-		$this->mountManager->remove($mount);
189
-	}
190
-
191
-	/**
192
-	 * @param string $path
193
-	 * @throws \OCP\Files\NotFoundException
194
-	 * @throws \OCP\Files\NotPermittedException
195
-	 * @return Node
196
-	 */
197
-	public function get($path) {
198
-		$path = $this->normalizePath($path);
199
-		if ($this->isValidPath($path)) {
200
-			$fullPath = $this->getFullPath($path);
201
-			$fileInfo = $this->view->getFileInfo($fullPath);
202
-			if ($fileInfo) {
203
-				return $this->createNode($fullPath, $fileInfo);
204
-			} else {
205
-				throw new NotFoundException($path);
206
-			}
207
-		} else {
208
-			throw new NotPermittedException();
209
-		}
210
-	}
211
-
212
-	//most operations can't be done on the root
213
-
214
-	/**
215
-	 * @param string $targetPath
216
-	 * @throws \OCP\Files\NotPermittedException
217
-	 * @return \OC\Files\Node\Node
218
-	 */
219
-	public function rename($targetPath) {
220
-		throw new NotPermittedException();
221
-	}
222
-
223
-	public function delete() {
224
-		throw new NotPermittedException();
225
-	}
226
-
227
-	/**
228
-	 * @param string $targetPath
229
-	 * @throws \OCP\Files\NotPermittedException
230
-	 * @return \OC\Files\Node\Node
231
-	 */
232
-	public function copy($targetPath) {
233
-		throw new NotPermittedException();
234
-	}
235
-
236
-	/**
237
-	 * @param int $mtime
238
-	 * @throws \OCP\Files\NotPermittedException
239
-	 */
240
-	public function touch($mtime = null) {
241
-		throw new NotPermittedException();
242
-	}
243
-
244
-	/**
245
-	 * @return \OC\Files\Storage\Storage
246
-	 * @throws \OCP\Files\NotFoundException
247
-	 */
248
-	public function getStorage() {
249
-		throw new NotFoundException();
250
-	}
251
-
252
-	/**
253
-	 * @return string
254
-	 */
255
-	public function getPath() {
256
-		return '/';
257
-	}
258
-
259
-	/**
260
-	 * @return string
261
-	 */
262
-	public function getInternalPath() {
263
-		return '';
264
-	}
265
-
266
-	/**
267
-	 * @return int
268
-	 */
269
-	public function getId() {
270
-		return null;
271
-	}
272
-
273
-	/**
274
-	 * @return array
275
-	 */
276
-	public function stat() {
277
-		return null;
278
-	}
279
-
280
-	/**
281
-	 * @return int
282
-	 */
283
-	public function getMTime() {
284
-		return null;
285
-	}
286
-
287
-	/**
288
-	 * @param bool $includeMounts
289
-	 * @return int
290
-	 */
291
-	public function getSize($includeMounts = true) {
292
-		return null;
293
-	}
294
-
295
-	/**
296
-	 * @return string
297
-	 */
298
-	public function getEtag() {
299
-		return null;
300
-	}
301
-
302
-	/**
303
-	 * @return int
304
-	 */
305
-	public function getPermissions() {
306
-		return \OCP\Constants::PERMISSION_CREATE;
307
-	}
308
-
309
-	/**
310
-	 * @return bool
311
-	 */
312
-	public function isReadable() {
313
-		return false;
314
-	}
315
-
316
-	/**
317
-	 * @return bool
318
-	 */
319
-	public function isUpdateable() {
320
-		return false;
321
-	}
322
-
323
-	/**
324
-	 * @return bool
325
-	 */
326
-	public function isDeletable() {
327
-		return false;
328
-	}
329
-
330
-	/**
331
-	 * @return bool
332
-	 */
333
-	public function isShareable() {
334
-		return false;
335
-	}
336
-
337
-	/**
338
-	 * @return Node
339
-	 * @throws \OCP\Files\NotFoundException
340
-	 */
341
-	public function getParent() {
342
-		throw new NotFoundException();
343
-	}
344
-
345
-	/**
346
-	 * @return string
347
-	 */
348
-	public function getName() {
349
-		return '';
350
-	}
351
-
352
-	/**
353
-	 * Returns a view to user's files folder
354
-	 *
355
-	 * @param string $userId user ID
356
-	 * @return \OCP\Files\Folder
357
-	 * @throws NoUserException
358
-	 * @throws NotPermittedException
359
-	 */
360
-	public function getUserFolder($userId) {
361
-		$userObject = $this->userManager->get($userId);
362
-
363
-		if (is_null($userObject)) {
364
-			$this->logger->error(
365
-				sprintf(
366
-					'Backends provided no user object for %s',
367
-					$userId
368
-				),
369
-				[
370
-					'app' => 'files',
371
-				]
372
-			);
373
-			throw new NoUserException('Backends provided no user object');
374
-		}
375
-
376
-		$userId = $userObject->getUID();
377
-
378
-		if (!$this->userFolderCache->hasKey($userId)) {
379
-			\OC\Files\Filesystem::initMountPoints($userId);
380
-
381
-			try {
382
-				$folder = $this->get('/' . $userId . '/files');
383
-			} catch (NotFoundException $e) {
384
-				if (!$this->nodeExists('/' . $userId)) {
385
-					$this->newFolder('/' . $userId);
386
-				}
387
-				$folder = $this->newFolder('/' . $userId . '/files');
388
-			}
389
-
390
-			$this->userFolderCache->set($userId, $folder);
391
-		}
392
-
393
-		return $this->userFolderCache->get($userId);
394
-	}
395
-
396
-	public function clearCache() {
397
-		$this->userFolderCache = new CappedMemoryCache();
398
-	}
399
-
400
-	public function getUserMountCache() {
401
-		return $this->userMountCache;
402
-	}
67
+    /** @var Manager */
68
+    private $mountManager;
69
+    /** @var PublicEmitter */
70
+    private $emitter;
71
+    /** @var null|\OC\User\User */
72
+    private $user;
73
+    /** @var CappedMemoryCache */
74
+    private $userFolderCache;
75
+    /** @var IUserMountCache */
76
+    private $userMountCache;
77
+    /** @var ILogger */
78
+    private $logger;
79
+    /** @var IUserManager */
80
+    private $userManager;
81
+
82
+    /**
83
+     * @param \OC\Files\Mount\Manager $manager
84
+     * @param \OC\Files\View $view
85
+     * @param \OC\User\User|null $user
86
+     * @param IUserMountCache $userMountCache
87
+     * @param ILogger $logger
88
+     * @param IUserManager $userManager
89
+     */
90
+    public function __construct($manager,
91
+                                $view,
92
+                                $user,
93
+                                IUserMountCache $userMountCache,
94
+                                ILogger $logger,
95
+                                IUserManager $userManager) {
96
+        parent::__construct($this, $view, '');
97
+        $this->mountManager = $manager;
98
+        $this->user = $user;
99
+        $this->emitter = new PublicEmitter();
100
+        $this->userFolderCache = new CappedMemoryCache();
101
+        $this->userMountCache = $userMountCache;
102
+        $this->logger = $logger;
103
+        $this->userManager = $userManager;
104
+    }
105
+
106
+    /**
107
+     * Get the user for which the filesystem is setup
108
+     *
109
+     * @return \OC\User\User
110
+     */
111
+    public function getUser() {
112
+        return $this->user;
113
+    }
114
+
115
+    /**
116
+     * @param string $scope
117
+     * @param string $method
118
+     * @param callable $callback
119
+     */
120
+    public function listen($scope, $method, callable $callback) {
121
+        $this->emitter->listen($scope, $method, $callback);
122
+    }
123
+
124
+    /**
125
+     * @param string $scope optional
126
+     * @param string $method optional
127
+     * @param callable $callback optional
128
+     */
129
+    public function removeListener($scope = null, $method = null, callable $callback = null) {
130
+        $this->emitter->removeListener($scope, $method, $callback);
131
+    }
132
+
133
+    /**
134
+     * @param string $scope
135
+     * @param string $method
136
+     * @param Node[] $arguments
137
+     */
138
+    public function emit($scope, $method, $arguments = []) {
139
+        $this->emitter->emit($scope, $method, $arguments);
140
+    }
141
+
142
+    /**
143
+     * @param \OC\Files\Storage\Storage $storage
144
+     * @param string $mountPoint
145
+     * @param array $arguments
146
+     */
147
+    public function mount($storage, $mountPoint, $arguments = []) {
148
+        $mount = new MountPoint($storage, $mountPoint, $arguments);
149
+        $this->mountManager->addMount($mount);
150
+    }
151
+
152
+    /**
153
+     * @param string $mountPoint
154
+     * @return \OC\Files\Mount\MountPoint
155
+     */
156
+    public function getMount($mountPoint) {
157
+        return $this->mountManager->find($mountPoint);
158
+    }
159
+
160
+    /**
161
+     * @param string $mountPoint
162
+     * @return \OC\Files\Mount\MountPoint[]
163
+     */
164
+    public function getMountsIn($mountPoint) {
165
+        return $this->mountManager->findIn($mountPoint);
166
+    }
167
+
168
+    /**
169
+     * @param string $storageId
170
+     * @return \OC\Files\Mount\MountPoint[]
171
+     */
172
+    public function getMountByStorageId($storageId) {
173
+        return $this->mountManager->findByStorageId($storageId);
174
+    }
175
+
176
+    /**
177
+     * @param int $numericId
178
+     * @return MountPoint[]
179
+     */
180
+    public function getMountByNumericStorageId($numericId) {
181
+        return $this->mountManager->findByNumericId($numericId);
182
+    }
183
+
184
+    /**
185
+     * @param \OC\Files\Mount\MountPoint $mount
186
+     */
187
+    public function unMount($mount) {
188
+        $this->mountManager->remove($mount);
189
+    }
190
+
191
+    /**
192
+     * @param string $path
193
+     * @throws \OCP\Files\NotFoundException
194
+     * @throws \OCP\Files\NotPermittedException
195
+     * @return Node
196
+     */
197
+    public function get($path) {
198
+        $path = $this->normalizePath($path);
199
+        if ($this->isValidPath($path)) {
200
+            $fullPath = $this->getFullPath($path);
201
+            $fileInfo = $this->view->getFileInfo($fullPath);
202
+            if ($fileInfo) {
203
+                return $this->createNode($fullPath, $fileInfo);
204
+            } else {
205
+                throw new NotFoundException($path);
206
+            }
207
+        } else {
208
+            throw new NotPermittedException();
209
+        }
210
+    }
211
+
212
+    //most operations can't be done on the root
213
+
214
+    /**
215
+     * @param string $targetPath
216
+     * @throws \OCP\Files\NotPermittedException
217
+     * @return \OC\Files\Node\Node
218
+     */
219
+    public function rename($targetPath) {
220
+        throw new NotPermittedException();
221
+    }
222
+
223
+    public function delete() {
224
+        throw new NotPermittedException();
225
+    }
226
+
227
+    /**
228
+     * @param string $targetPath
229
+     * @throws \OCP\Files\NotPermittedException
230
+     * @return \OC\Files\Node\Node
231
+     */
232
+    public function copy($targetPath) {
233
+        throw new NotPermittedException();
234
+    }
235
+
236
+    /**
237
+     * @param int $mtime
238
+     * @throws \OCP\Files\NotPermittedException
239
+     */
240
+    public function touch($mtime = null) {
241
+        throw new NotPermittedException();
242
+    }
243
+
244
+    /**
245
+     * @return \OC\Files\Storage\Storage
246
+     * @throws \OCP\Files\NotFoundException
247
+     */
248
+    public function getStorage() {
249
+        throw new NotFoundException();
250
+    }
251
+
252
+    /**
253
+     * @return string
254
+     */
255
+    public function getPath() {
256
+        return '/';
257
+    }
258
+
259
+    /**
260
+     * @return string
261
+     */
262
+    public function getInternalPath() {
263
+        return '';
264
+    }
265
+
266
+    /**
267
+     * @return int
268
+     */
269
+    public function getId() {
270
+        return null;
271
+    }
272
+
273
+    /**
274
+     * @return array
275
+     */
276
+    public function stat() {
277
+        return null;
278
+    }
279
+
280
+    /**
281
+     * @return int
282
+     */
283
+    public function getMTime() {
284
+        return null;
285
+    }
286
+
287
+    /**
288
+     * @param bool $includeMounts
289
+     * @return int
290
+     */
291
+    public function getSize($includeMounts = true) {
292
+        return null;
293
+    }
294
+
295
+    /**
296
+     * @return string
297
+     */
298
+    public function getEtag() {
299
+        return null;
300
+    }
301
+
302
+    /**
303
+     * @return int
304
+     */
305
+    public function getPermissions() {
306
+        return \OCP\Constants::PERMISSION_CREATE;
307
+    }
308
+
309
+    /**
310
+     * @return bool
311
+     */
312
+    public function isReadable() {
313
+        return false;
314
+    }
315
+
316
+    /**
317
+     * @return bool
318
+     */
319
+    public function isUpdateable() {
320
+        return false;
321
+    }
322
+
323
+    /**
324
+     * @return bool
325
+     */
326
+    public function isDeletable() {
327
+        return false;
328
+    }
329
+
330
+    /**
331
+     * @return bool
332
+     */
333
+    public function isShareable() {
334
+        return false;
335
+    }
336
+
337
+    /**
338
+     * @return Node
339
+     * @throws \OCP\Files\NotFoundException
340
+     */
341
+    public function getParent() {
342
+        throw new NotFoundException();
343
+    }
344
+
345
+    /**
346
+     * @return string
347
+     */
348
+    public function getName() {
349
+        return '';
350
+    }
351
+
352
+    /**
353
+     * Returns a view to user's files folder
354
+     *
355
+     * @param string $userId user ID
356
+     * @return \OCP\Files\Folder
357
+     * @throws NoUserException
358
+     * @throws NotPermittedException
359
+     */
360
+    public function getUserFolder($userId) {
361
+        $userObject = $this->userManager->get($userId);
362
+
363
+        if (is_null($userObject)) {
364
+            $this->logger->error(
365
+                sprintf(
366
+                    'Backends provided no user object for %s',
367
+                    $userId
368
+                ),
369
+                [
370
+                    'app' => 'files',
371
+                ]
372
+            );
373
+            throw new NoUserException('Backends provided no user object');
374
+        }
375
+
376
+        $userId = $userObject->getUID();
377
+
378
+        if (!$this->userFolderCache->hasKey($userId)) {
379
+            \OC\Files\Filesystem::initMountPoints($userId);
380
+
381
+            try {
382
+                $folder = $this->get('/' . $userId . '/files');
383
+            } catch (NotFoundException $e) {
384
+                if (!$this->nodeExists('/' . $userId)) {
385
+                    $this->newFolder('/' . $userId);
386
+                }
387
+                $folder = $this->newFolder('/' . $userId . '/files');
388
+            }
389
+
390
+            $this->userFolderCache->set($userId, $folder);
391
+        }
392
+
393
+        return $this->userFolderCache->get($userId);
394
+    }
395
+
396
+    public function clearCache() {
397
+        $this->userFolderCache = new CappedMemoryCache();
398
+    }
399
+
400
+    public function getUserMountCache() {
401
+        return $this->userMountCache;
402
+    }
403 403
 }
Please login to merge, or discard this patch.
lib/private/Files/Mount/ObjectHomeMountProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 			return null;
65 65
 		}
66 66
 
67
-		return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader);
67
+		return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/'.$user->getUID(), $config['arguments'], $loader);
68 68
 	}
69 69
 
70 70
 	/**
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -35,107 +35,107 @@
 block discarded – undo
35 35
  * Mount provider for object store home storages
36 36
  */
37 37
 class ObjectHomeMountProvider implements IHomeMountProvider {
38
-	/**
39
-	 * @var IConfig
40
-	 */
41
-	private $config;
42
-
43
-	/**
44
-	 * ObjectStoreHomeMountProvider constructor.
45
-	 *
46
-	 * @param IConfig $config
47
-	 */
48
-	public function __construct(IConfig $config) {
49
-		$this->config = $config;
50
-	}
51
-
52
-	/**
53
-	 * Get the cache mount for a user
54
-	 *
55
-	 * @param IUser $user
56
-	 * @param IStorageFactory $loader
57
-	 * @return \OCP\Files\Mount\IMountPoint
58
-	 */
59
-	public function getHomeMountForUser(IUser $user, IStorageFactory $loader) {
60
-		$config = $this->getMultiBucketObjectStoreConfig($user);
61
-		if ($config === null) {
62
-			$config = $this->getSingleBucketObjectStoreConfig($user);
63
-		}
64
-
65
-		if ($config === null) {
66
-			return null;
67
-		}
68
-
69
-		return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader);
70
-	}
71
-
72
-	/**
73
-	 * @param IUser $user
74
-	 * @return array|null
75
-	 */
76
-	private function getSingleBucketObjectStoreConfig(IUser $user) {
77
-		$config = $this->config->getSystemValue('objectstore');
78
-		if (!is_array($config)) {
79
-			return null;
80
-		}
81
-
82
-		// sanity checks
83
-		if (empty($config['class'])) {
84
-			\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
85
-		}
86
-		if (!isset($config['arguments'])) {
87
-			$config['arguments'] = [];
88
-		}
89
-		// instantiate object store implementation
90
-		$config['arguments']['objectstore'] = new $config['class']($config['arguments']);
91
-
92
-		$config['arguments']['user'] = $user;
93
-
94
-		return $config;
95
-	}
96
-
97
-	/**
98
-	 * @param IUser $user
99
-	 * @return array|null
100
-	 */
101
-	private function getMultiBucketObjectStoreConfig(IUser $user) {
102
-		$config = $this->config->getSystemValue('objectstore_multibucket');
103
-		if (!is_array($config)) {
104
-			return null;
105
-		}
106
-
107
-		// sanity checks
108
-		if (empty($config['class'])) {
109
-			\OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
110
-		}
111
-		if (!isset($config['arguments'])) {
112
-			$config['arguments'] = [];
113
-		}
114
-
115
-		$bucket = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null);
116
-
117
-		if ($bucket === null) {
118
-			/*
38
+    /**
39
+     * @var IConfig
40
+     */
41
+    private $config;
42
+
43
+    /**
44
+     * ObjectStoreHomeMountProvider constructor.
45
+     *
46
+     * @param IConfig $config
47
+     */
48
+    public function __construct(IConfig $config) {
49
+        $this->config = $config;
50
+    }
51
+
52
+    /**
53
+     * Get the cache mount for a user
54
+     *
55
+     * @param IUser $user
56
+     * @param IStorageFactory $loader
57
+     * @return \OCP\Files\Mount\IMountPoint
58
+     */
59
+    public function getHomeMountForUser(IUser $user, IStorageFactory $loader) {
60
+        $config = $this->getMultiBucketObjectStoreConfig($user);
61
+        if ($config === null) {
62
+            $config = $this->getSingleBucketObjectStoreConfig($user);
63
+        }
64
+
65
+        if ($config === null) {
66
+            return null;
67
+        }
68
+
69
+        return new MountPoint('\OC\Files\ObjectStore\HomeObjectStoreStorage', '/' . $user->getUID(), $config['arguments'], $loader);
70
+    }
71
+
72
+    /**
73
+     * @param IUser $user
74
+     * @return array|null
75
+     */
76
+    private function getSingleBucketObjectStoreConfig(IUser $user) {
77
+        $config = $this->config->getSystemValue('objectstore');
78
+        if (!is_array($config)) {
79
+            return null;
80
+        }
81
+
82
+        // sanity checks
83
+        if (empty($config['class'])) {
84
+            \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
85
+        }
86
+        if (!isset($config['arguments'])) {
87
+            $config['arguments'] = [];
88
+        }
89
+        // instantiate object store implementation
90
+        $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
91
+
92
+        $config['arguments']['user'] = $user;
93
+
94
+        return $config;
95
+    }
96
+
97
+    /**
98
+     * @param IUser $user
99
+     * @return array|null
100
+     */
101
+    private function getMultiBucketObjectStoreConfig(IUser $user) {
102
+        $config = $this->config->getSystemValue('objectstore_multibucket');
103
+        if (!is_array($config)) {
104
+            return null;
105
+        }
106
+
107
+        // sanity checks
108
+        if (empty($config['class'])) {
109
+            \OCP\Util::writeLog('files', 'No class given for objectstore', ILogger::ERROR);
110
+        }
111
+        if (!isset($config['arguments'])) {
112
+            $config['arguments'] = [];
113
+        }
114
+
115
+        $bucket = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null);
116
+
117
+        if ($bucket === null) {
118
+            /*
119 119
 			 * Use any provided bucket argument as prefix
120 120
 			 * and add the mapping from username => bucket
121 121
 			 */
122
-			if (!isset($config['arguments']['bucket'])) {
123
-				$config['arguments']['bucket'] = '';
124
-			}
125
-			$mapper = new \OC\Files\ObjectStore\Mapper($user);
126
-			$numBuckets = isset($config['arguments']['num_buckets']) ? $config['arguments']['num_buckets'] : 64;
127
-			$config['arguments']['bucket'] .= $mapper->getBucket($numBuckets);
122
+            if (!isset($config['arguments']['bucket'])) {
123
+                $config['arguments']['bucket'] = '';
124
+            }
125
+            $mapper = new \OC\Files\ObjectStore\Mapper($user);
126
+            $numBuckets = isset($config['arguments']['num_buckets']) ? $config['arguments']['num_buckets'] : 64;
127
+            $config['arguments']['bucket'] .= $mapper->getBucket($numBuckets);
128 128
 
129
-			$this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $config['arguments']['bucket']);
130
-		} else {
131
-			$config['arguments']['bucket'] = $bucket;
132
-		}
129
+            $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $config['arguments']['bucket']);
130
+        } else {
131
+            $config['arguments']['bucket'] = $bucket;
132
+        }
133 133
 
134
-		// instantiate object store implementation
135
-		$config['arguments']['objectstore'] = new $config['class']($config['arguments']);
134
+        // instantiate object store implementation
135
+        $config['arguments']['objectstore'] = new $config['class']($config['arguments']);
136 136
 
137
-		$config['arguments']['user'] = $user;
137
+        $config['arguments']['user'] = $user;
138 138
 
139
-		return $config;
140
-	}
139
+        return $config;
140
+    }
141 141
 }
Please login to merge, or discard this patch.