Passed
Push — master ( 9035be...9f2495 )
by Julius
17:19 queued 12s
created
lib/private/Command/CommandJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  * Wrap a command in the background job interface
30 30
  */
31 31
 class CommandJob extends QueuedJob {
32
-	protected function run($serializedCommand) {
33
-		$command = unserialize($serializedCommand);
34
-		if ($command instanceof ICommand) {
35
-			$command->handle();
36
-		} else {
37
-			throw new \InvalidArgumentException('Invalid serialized command');
38
-		}
39
-	}
32
+    protected function run($serializedCommand) {
33
+        $command = unserialize($serializedCommand);
34
+        if ($command instanceof ICommand) {
35
+            $command->handle();
36
+        } else {
37
+            throw new \InvalidArgumentException('Invalid serialized command');
38
+        }
39
+    }
40 40
 }
Please login to merge, or discard this patch.
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/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/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/Files/Config/UserMountCacheListener.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@
 block discarded – undo
29 29
  * Listen to hooks and update the mount cache as needed
30 30
  */
31 31
 class UserMountCacheListener {
32
-	/**
33
-	 * @var IUserMountCache
34
-	 */
35
-	private $userMountCache;
32
+    /**
33
+     * @var IUserMountCache
34
+     */
35
+    private $userMountCache;
36 36
 
37
-	/**
38
-	 * UserMountCacheListener constructor.
39
-	 *
40
-	 * @param IUserMountCache $userMountCache
41
-	 */
42
-	public function __construct(IUserMountCache $userMountCache) {
43
-		$this->userMountCache = $userMountCache;
44
-	}
37
+    /**
38
+     * UserMountCacheListener constructor.
39
+     *
40
+     * @param IUserMountCache $userMountCache
41
+     */
42
+    public function __construct(IUserMountCache $userMountCache) {
43
+        $this->userMountCache = $userMountCache;
44
+    }
45 45
 
46
-	public function listen(Manager $manager) {
47
-		$manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
-	}
46
+    public function listen(Manager $manager) {
47
+        $manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']);
48
+    }
49 49
 }
Please login to merge, or discard this patch.
lib/private/Files/Storage/Wrapper/Encoding.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				// no point in continuing if the section was not found, use original path
81 81
 				return $fullPath;
82 82
 			}
83
-			$path = $convertedPath . '/';
83
+			$path = $convertedPath.'/';
84 84
 		}
85 85
 		$path = rtrim($path, '/');
86 86
 		return $path;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return string|null original or converted path, or null if none of the forms was found
97 97
 	 */
98 98
 	private function findPathToUseLastSection($basePath, $lastSection) {
99
-		$fullPath = $basePath . $lastSection;
99
+		$fullPath = $basePath.$lastSection;
100 100
 		if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) {
101 101
 			$this->namesCache[$fullPath] = $fullPath;
102 102
 			return $fullPath;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		} else {
109 109
 			$otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C);
110 110
 		}
111
-		$otherFullPath = $basePath . $otherFormPath;
111
+		$otherFullPath = $basePath.$otherFormPath;
112 112
 		if ($this->storage->file_exists($otherFullPath)) {
113 113
 			$this->namesCache[$fullPath] = $otherFullPath;
114 114
 			return $otherFullPath;
Please login to merge, or discard this patch.
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -40,509 +40,509 @@
 block discarded – undo
40 40
  * the actual given name and then try its NFD form.
41 41
  */
42 42
 class Encoding extends Wrapper {
43
-	/**
44
-	 * @var ICache
45
-	 */
46
-	private $namesCache;
47
-
48
-	/**
49
-	 * @param array $parameters
50
-	 */
51
-	public function __construct($parameters) {
52
-		$this->storage = $parameters['storage'];
53
-		$this->namesCache = new CappedMemoryCache();
54
-	}
55
-
56
-	/**
57
-	 * Returns whether the given string is only made of ASCII characters
58
-	 *
59
-	 * @param string $str string
60
-	 *
61
-	 * @return bool true if the string is all ASCII, false otherwise
62
-	 */
63
-	private function isAscii($str) {
64
-		return !preg_match('/[\\x80-\\xff]+/', $str);
65
-	}
66
-
67
-	/**
68
-	 * Checks whether the given path exists in NFC or NFD form after checking
69
-	 * each form for each path section and returns the correct form.
70
-	 * If no existing path found, returns the path as it was given.
71
-	 *
72
-	 * @param string $fullPath path to check
73
-	 *
74
-	 * @return string original or converted path
75
-	 */
76
-	private function findPathToUse($fullPath) {
77
-		$cachedPath = $this->namesCache[$fullPath];
78
-		if ($cachedPath !== null) {
79
-			return $cachedPath;
80
-		}
81
-
82
-		$sections = explode('/', $fullPath);
83
-		$path = '';
84
-		foreach ($sections as $section) {
85
-			$convertedPath = $this->findPathToUseLastSection($path, $section);
86
-			if ($convertedPath === null) {
87
-				// no point in continuing if the section was not found, use original path
88
-				return $fullPath;
89
-			}
90
-			$path = $convertedPath . '/';
91
-		}
92
-		$path = rtrim($path, '/');
93
-		return $path;
94
-	}
95
-
96
-	/**
97
-	 * Checks whether the last path section of the given path exists in NFC or NFD form
98
-	 * and returns the correct form. If no existing path found, returns null.
99
-	 *
100
-	 * @param string $basePath base path to check
101
-	 * @param string $lastSection last section of the path to check for NFD/NFC variations
102
-	 *
103
-	 * @return string|null original or converted path, or null if none of the forms was found
104
-	 */
105
-	private function findPathToUseLastSection($basePath, $lastSection) {
106
-		$fullPath = $basePath . $lastSection;
107
-		if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) {
108
-			$this->namesCache[$fullPath] = $fullPath;
109
-			return $fullPath;
110
-		}
111
-
112
-		// swap encoding
113
-		if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) {
114
-			$otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D);
115
-		} else {
116
-			$otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C);
117
-		}
118
-		$otherFullPath = $basePath . $otherFormPath;
119
-		if ($this->storage->file_exists($otherFullPath)) {
120
-			$this->namesCache[$fullPath] = $otherFullPath;
121
-			return $otherFullPath;
122
-		}
123
-
124
-		// return original path, file did not exist at all
125
-		$this->namesCache[$fullPath] = $fullPath;
126
-		return null;
127
-	}
128
-
129
-	/**
130
-	 * see https://www.php.net/manual/en/function.mkdir.php
131
-	 *
132
-	 * @param string $path
133
-	 * @return bool
134
-	 */
135
-	public function mkdir($path) {
136
-		// note: no conversion here, method should not be called with non-NFC names!
137
-		$result = $this->storage->mkdir($path);
138
-		if ($result) {
139
-			$this->namesCache[$path] = $path;
140
-		}
141
-		return $result;
142
-	}
143
-
144
-	/**
145
-	 * see https://www.php.net/manual/en/function.rmdir.php
146
-	 *
147
-	 * @param string $path
148
-	 * @return bool
149
-	 */
150
-	public function rmdir($path) {
151
-		$result = $this->storage->rmdir($this->findPathToUse($path));
152
-		if ($result) {
153
-			unset($this->namesCache[$path]);
154
-		}
155
-		return $result;
156
-	}
157
-
158
-	/**
159
-	 * see https://www.php.net/manual/en/function.opendir.php
160
-	 *
161
-	 * @param string $path
162
-	 * @return resource|bool
163
-	 */
164
-	public function opendir($path) {
165
-		$handle = $this->storage->opendir($this->findPathToUse($path));
166
-		return EncodingDirectoryWrapper::wrap($handle);
167
-	}
168
-
169
-	/**
170
-	 * see https://www.php.net/manual/en/function.is_dir.php
171
-	 *
172
-	 * @param string $path
173
-	 * @return bool
174
-	 */
175
-	public function is_dir($path) {
176
-		return $this->storage->is_dir($this->findPathToUse($path));
177
-	}
178
-
179
-	/**
180
-	 * see https://www.php.net/manual/en/function.is_file.php
181
-	 *
182
-	 * @param string $path
183
-	 * @return bool
184
-	 */
185
-	public function is_file($path) {
186
-		return $this->storage->is_file($this->findPathToUse($path));
187
-	}
188
-
189
-	/**
190
-	 * see https://www.php.net/manual/en/function.stat.php
191
-	 * only the following keys are required in the result: size and mtime
192
-	 *
193
-	 * @param string $path
194
-	 * @return array|bool
195
-	 */
196
-	public function stat($path) {
197
-		return $this->storage->stat($this->findPathToUse($path));
198
-	}
199
-
200
-	/**
201
-	 * see https://www.php.net/manual/en/function.filetype.php
202
-	 *
203
-	 * @param string $path
204
-	 * @return string|bool
205
-	 */
206
-	public function filetype($path) {
207
-		return $this->storage->filetype($this->findPathToUse($path));
208
-	}
209
-
210
-	/**
211
-	 * see https://www.php.net/manual/en/function.filesize.php
212
-	 * The result for filesize when called on a folder is required to be 0
213
-	 *
214
-	 * @param string $path
215
-	 * @return int|bool
216
-	 */
217
-	public function filesize($path) {
218
-		return $this->storage->filesize($this->findPathToUse($path));
219
-	}
220
-
221
-	/**
222
-	 * check if a file can be created in $path
223
-	 *
224
-	 * @param string $path
225
-	 * @return bool
226
-	 */
227
-	public function isCreatable($path) {
228
-		return $this->storage->isCreatable($this->findPathToUse($path));
229
-	}
230
-
231
-	/**
232
-	 * check if a file can be read
233
-	 *
234
-	 * @param string $path
235
-	 * @return bool
236
-	 */
237
-	public function isReadable($path) {
238
-		return $this->storage->isReadable($this->findPathToUse($path));
239
-	}
240
-
241
-	/**
242
-	 * check if a file can be written to
243
-	 *
244
-	 * @param string $path
245
-	 * @return bool
246
-	 */
247
-	public function isUpdatable($path) {
248
-		return $this->storage->isUpdatable($this->findPathToUse($path));
249
-	}
250
-
251
-	/**
252
-	 * check if a file can be deleted
253
-	 *
254
-	 * @param string $path
255
-	 * @return bool
256
-	 */
257
-	public function isDeletable($path) {
258
-		return $this->storage->isDeletable($this->findPathToUse($path));
259
-	}
260
-
261
-	/**
262
-	 * check if a file can be shared
263
-	 *
264
-	 * @param string $path
265
-	 * @return bool
266
-	 */
267
-	public function isSharable($path) {
268
-		return $this->storage->isSharable($this->findPathToUse($path));
269
-	}
270
-
271
-	/**
272
-	 * get the full permissions of a path.
273
-	 * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
274
-	 *
275
-	 * @param string $path
276
-	 * @return int
277
-	 */
278
-	public function getPermissions($path) {
279
-		return $this->storage->getPermissions($this->findPathToUse($path));
280
-	}
281
-
282
-	/**
283
-	 * see https://www.php.net/manual/en/function.file_exists.php
284
-	 *
285
-	 * @param string $path
286
-	 * @return bool
287
-	 */
288
-	public function file_exists($path) {
289
-		return $this->storage->file_exists($this->findPathToUse($path));
290
-	}
291
-
292
-	/**
293
-	 * see https://www.php.net/manual/en/function.filemtime.php
294
-	 *
295
-	 * @param string $path
296
-	 * @return int|bool
297
-	 */
298
-	public function filemtime($path) {
299
-		return $this->storage->filemtime($this->findPathToUse($path));
300
-	}
301
-
302
-	/**
303
-	 * see https://www.php.net/manual/en/function.file_get_contents.php
304
-	 *
305
-	 * @param string $path
306
-	 * @return string|bool
307
-	 */
308
-	public function file_get_contents($path) {
309
-		return $this->storage->file_get_contents($this->findPathToUse($path));
310
-	}
311
-
312
-	/**
313
-	 * see https://www.php.net/manual/en/function.file_put_contents.php
314
-	 *
315
-	 * @param string $path
316
-	 * @param mixed $data
317
-	 * @return int|false
318
-	 */
319
-	public function file_put_contents($path, $data) {
320
-		return $this->storage->file_put_contents($this->findPathToUse($path), $data);
321
-	}
322
-
323
-	/**
324
-	 * see https://www.php.net/manual/en/function.unlink.php
325
-	 *
326
-	 * @param string $path
327
-	 * @return bool
328
-	 */
329
-	public function unlink($path) {
330
-		$result = $this->storage->unlink($this->findPathToUse($path));
331
-		if ($result) {
332
-			unset($this->namesCache[$path]);
333
-		}
334
-		return $result;
335
-	}
336
-
337
-	/**
338
-	 * see https://www.php.net/manual/en/function.rename.php
339
-	 *
340
-	 * @param string $source
341
-	 * @param string $target
342
-	 * @return bool
343
-	 */
344
-	public function rename($source, $target) {
345
-		// second name always NFC
346
-		return $this->storage->rename($this->findPathToUse($source), $this->findPathToUse($target));
347
-	}
348
-
349
-	/**
350
-	 * see https://www.php.net/manual/en/function.copy.php
351
-	 *
352
-	 * @param string $source
353
-	 * @param string $target
354
-	 * @return bool
355
-	 */
356
-	public function copy($source, $target) {
357
-		return $this->storage->copy($this->findPathToUse($source), $this->findPathToUse($target));
358
-	}
359
-
360
-	/**
361
-	 * see https://www.php.net/manual/en/function.fopen.php
362
-	 *
363
-	 * @param string $path
364
-	 * @param string $mode
365
-	 * @return resource|bool
366
-	 */
367
-	public function fopen($path, $mode) {
368
-		$result = $this->storage->fopen($this->findPathToUse($path), $mode);
369
-		if ($result && $mode !== 'r' && $mode !== 'rb') {
370
-			unset($this->namesCache[$path]);
371
-		}
372
-		return $result;
373
-	}
374
-
375
-	/**
376
-	 * get the mimetype for a file or folder
377
-	 * The mimetype for a folder is required to be "httpd/unix-directory"
378
-	 *
379
-	 * @param string $path
380
-	 * @return string|bool
381
-	 */
382
-	public function getMimeType($path) {
383
-		return $this->storage->getMimeType($this->findPathToUse($path));
384
-	}
385
-
386
-	/**
387
-	 * see https://www.php.net/manual/en/function.hash.php
388
-	 *
389
-	 * @param string $type
390
-	 * @param string $path
391
-	 * @param bool $raw
392
-	 * @return string|bool
393
-	 */
394
-	public function hash($type, $path, $raw = false) {
395
-		return $this->storage->hash($type, $this->findPathToUse($path), $raw);
396
-	}
397
-
398
-	/**
399
-	 * see https://www.php.net/manual/en/function.free_space.php
400
-	 *
401
-	 * @param string $path
402
-	 * @return int|bool
403
-	 */
404
-	public function free_space($path) {
405
-		return $this->storage->free_space($this->findPathToUse($path));
406
-	}
407
-
408
-	/**
409
-	 * search for occurrences of $query in file names
410
-	 *
411
-	 * @param string $query
412
-	 * @return array|bool
413
-	 */
414
-	public function search($query) {
415
-		return $this->storage->search($query);
416
-	}
417
-
418
-	/**
419
-	 * see https://www.php.net/manual/en/function.touch.php
420
-	 * If the backend does not support the operation, false should be returned
421
-	 *
422
-	 * @param string $path
423
-	 * @param int $mtime
424
-	 * @return bool
425
-	 */
426
-	public function touch($path, $mtime = null) {
427
-		return $this->storage->touch($this->findPathToUse($path), $mtime);
428
-	}
429
-
430
-	/**
431
-	 * get the path to a local version of the file.
432
-	 * The local version of the file can be temporary and doesn't have to be persistent across requests
433
-	 *
434
-	 * @param string $path
435
-	 * @return string|bool
436
-	 */
437
-	public function getLocalFile($path) {
438
-		return $this->storage->getLocalFile($this->findPathToUse($path));
439
-	}
440
-
441
-	/**
442
-	 * check if a file or folder has been updated since $time
443
-	 *
444
-	 * @param string $path
445
-	 * @param int $time
446
-	 * @return bool
447
-	 *
448
-	 * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
449
-	 * returning true for other changes in the folder is optional
450
-	 */
451
-	public function hasUpdated($path, $time) {
452
-		return $this->storage->hasUpdated($this->findPathToUse($path), $time);
453
-	}
454
-
455
-	/**
456
-	 * get a cache instance for the storage
457
-	 *
458
-	 * @param string $path
459
-	 * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
460
-	 * @return \OC\Files\Cache\Cache
461
-	 */
462
-	public function getCache($path = '', $storage = null) {
463
-		if (!$storage) {
464
-			$storage = $this;
465
-		}
466
-		return $this->storage->getCache($this->findPathToUse($path), $storage);
467
-	}
468
-
469
-	/**
470
-	 * get a scanner instance for the storage
471
-	 *
472
-	 * @param string $path
473
-	 * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
474
-	 * @return \OC\Files\Cache\Scanner
475
-	 */
476
-	public function getScanner($path = '', $storage = null) {
477
-		if (!$storage) {
478
-			$storage = $this;
479
-		}
480
-		return $this->storage->getScanner($this->findPathToUse($path), $storage);
481
-	}
482
-
483
-	/**
484
-	 * get the ETag for a file or folder
485
-	 *
486
-	 * @param string $path
487
-	 * @return string|bool
488
-	 */
489
-	public function getETag($path) {
490
-		return $this->storage->getETag($this->findPathToUse($path));
491
-	}
492
-
493
-	/**
494
-	 * @param IStorage $sourceStorage
495
-	 * @param string $sourceInternalPath
496
-	 * @param string $targetInternalPath
497
-	 * @return bool
498
-	 */
499
-	public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
500
-		if ($sourceStorage === $this) {
501
-			return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath));
502
-		}
503
-
504
-		$result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath));
505
-		if ($result) {
506
-			unset($this->namesCache[$targetInternalPath]);
507
-		}
508
-		return $result;
509
-	}
510
-
511
-	/**
512
-	 * @param IStorage $sourceStorage
513
-	 * @param string $sourceInternalPath
514
-	 * @param string $targetInternalPath
515
-	 * @return bool
516
-	 */
517
-	public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
518
-		if ($sourceStorage === $this) {
519
-			$result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath));
520
-			if ($result) {
521
-				unset($this->namesCache[$sourceInternalPath]);
522
-				unset($this->namesCache[$targetInternalPath]);
523
-			}
524
-			return $result;
525
-		}
526
-
527
-		$result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath));
528
-		if ($result) {
529
-			unset($this->namesCache[$sourceInternalPath]);
530
-			unset($this->namesCache[$targetInternalPath]);
531
-		}
532
-		return $result;
533
-	}
534
-
535
-	public function getMetaData($path) {
536
-		$entry = $this->storage->getMetaData($this->findPathToUse($path));
537
-		$entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/');
538
-		return $entry;
539
-	}
540
-
541
-	public function getDirectoryContent($directory): \Traversable {
542
-		$entries = $this->storage->getDirectoryContent($this->findPathToUse($directory));
543
-		foreach ($entries as $entry) {
544
-			$entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/');
545
-			yield $entry;
546
-		}
547
-	}
43
+    /**
44
+     * @var ICache
45
+     */
46
+    private $namesCache;
47
+
48
+    /**
49
+     * @param array $parameters
50
+     */
51
+    public function __construct($parameters) {
52
+        $this->storage = $parameters['storage'];
53
+        $this->namesCache = new CappedMemoryCache();
54
+    }
55
+
56
+    /**
57
+     * Returns whether the given string is only made of ASCII characters
58
+     *
59
+     * @param string $str string
60
+     *
61
+     * @return bool true if the string is all ASCII, false otherwise
62
+     */
63
+    private function isAscii($str) {
64
+        return !preg_match('/[\\x80-\\xff]+/', $str);
65
+    }
66
+
67
+    /**
68
+     * Checks whether the given path exists in NFC or NFD form after checking
69
+     * each form for each path section and returns the correct form.
70
+     * If no existing path found, returns the path as it was given.
71
+     *
72
+     * @param string $fullPath path to check
73
+     *
74
+     * @return string original or converted path
75
+     */
76
+    private function findPathToUse($fullPath) {
77
+        $cachedPath = $this->namesCache[$fullPath];
78
+        if ($cachedPath !== null) {
79
+            return $cachedPath;
80
+        }
81
+
82
+        $sections = explode('/', $fullPath);
83
+        $path = '';
84
+        foreach ($sections as $section) {
85
+            $convertedPath = $this->findPathToUseLastSection($path, $section);
86
+            if ($convertedPath === null) {
87
+                // no point in continuing if the section was not found, use original path
88
+                return $fullPath;
89
+            }
90
+            $path = $convertedPath . '/';
91
+        }
92
+        $path = rtrim($path, '/');
93
+        return $path;
94
+    }
95
+
96
+    /**
97
+     * Checks whether the last path section of the given path exists in NFC or NFD form
98
+     * and returns the correct form. If no existing path found, returns null.
99
+     *
100
+     * @param string $basePath base path to check
101
+     * @param string $lastSection last section of the path to check for NFD/NFC variations
102
+     *
103
+     * @return string|null original or converted path, or null if none of the forms was found
104
+     */
105
+    private function findPathToUseLastSection($basePath, $lastSection) {
106
+        $fullPath = $basePath . $lastSection;
107
+        if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) {
108
+            $this->namesCache[$fullPath] = $fullPath;
109
+            return $fullPath;
110
+        }
111
+
112
+        // swap encoding
113
+        if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) {
114
+            $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D);
115
+        } else {
116
+            $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C);
117
+        }
118
+        $otherFullPath = $basePath . $otherFormPath;
119
+        if ($this->storage->file_exists($otherFullPath)) {
120
+            $this->namesCache[$fullPath] = $otherFullPath;
121
+            return $otherFullPath;
122
+        }
123
+
124
+        // return original path, file did not exist at all
125
+        $this->namesCache[$fullPath] = $fullPath;
126
+        return null;
127
+    }
128
+
129
+    /**
130
+     * see https://www.php.net/manual/en/function.mkdir.php
131
+     *
132
+     * @param string $path
133
+     * @return bool
134
+     */
135
+    public function mkdir($path) {
136
+        // note: no conversion here, method should not be called with non-NFC names!
137
+        $result = $this->storage->mkdir($path);
138
+        if ($result) {
139
+            $this->namesCache[$path] = $path;
140
+        }
141
+        return $result;
142
+    }
143
+
144
+    /**
145
+     * see https://www.php.net/manual/en/function.rmdir.php
146
+     *
147
+     * @param string $path
148
+     * @return bool
149
+     */
150
+    public function rmdir($path) {
151
+        $result = $this->storage->rmdir($this->findPathToUse($path));
152
+        if ($result) {
153
+            unset($this->namesCache[$path]);
154
+        }
155
+        return $result;
156
+    }
157
+
158
+    /**
159
+     * see https://www.php.net/manual/en/function.opendir.php
160
+     *
161
+     * @param string $path
162
+     * @return resource|bool
163
+     */
164
+    public function opendir($path) {
165
+        $handle = $this->storage->opendir($this->findPathToUse($path));
166
+        return EncodingDirectoryWrapper::wrap($handle);
167
+    }
168
+
169
+    /**
170
+     * see https://www.php.net/manual/en/function.is_dir.php
171
+     *
172
+     * @param string $path
173
+     * @return bool
174
+     */
175
+    public function is_dir($path) {
176
+        return $this->storage->is_dir($this->findPathToUse($path));
177
+    }
178
+
179
+    /**
180
+     * see https://www.php.net/manual/en/function.is_file.php
181
+     *
182
+     * @param string $path
183
+     * @return bool
184
+     */
185
+    public function is_file($path) {
186
+        return $this->storage->is_file($this->findPathToUse($path));
187
+    }
188
+
189
+    /**
190
+     * see https://www.php.net/manual/en/function.stat.php
191
+     * only the following keys are required in the result: size and mtime
192
+     *
193
+     * @param string $path
194
+     * @return array|bool
195
+     */
196
+    public function stat($path) {
197
+        return $this->storage->stat($this->findPathToUse($path));
198
+    }
199
+
200
+    /**
201
+     * see https://www.php.net/manual/en/function.filetype.php
202
+     *
203
+     * @param string $path
204
+     * @return string|bool
205
+     */
206
+    public function filetype($path) {
207
+        return $this->storage->filetype($this->findPathToUse($path));
208
+    }
209
+
210
+    /**
211
+     * see https://www.php.net/manual/en/function.filesize.php
212
+     * The result for filesize when called on a folder is required to be 0
213
+     *
214
+     * @param string $path
215
+     * @return int|bool
216
+     */
217
+    public function filesize($path) {
218
+        return $this->storage->filesize($this->findPathToUse($path));
219
+    }
220
+
221
+    /**
222
+     * check if a file can be created in $path
223
+     *
224
+     * @param string $path
225
+     * @return bool
226
+     */
227
+    public function isCreatable($path) {
228
+        return $this->storage->isCreatable($this->findPathToUse($path));
229
+    }
230
+
231
+    /**
232
+     * check if a file can be read
233
+     *
234
+     * @param string $path
235
+     * @return bool
236
+     */
237
+    public function isReadable($path) {
238
+        return $this->storage->isReadable($this->findPathToUse($path));
239
+    }
240
+
241
+    /**
242
+     * check if a file can be written to
243
+     *
244
+     * @param string $path
245
+     * @return bool
246
+     */
247
+    public function isUpdatable($path) {
248
+        return $this->storage->isUpdatable($this->findPathToUse($path));
249
+    }
250
+
251
+    /**
252
+     * check if a file can be deleted
253
+     *
254
+     * @param string $path
255
+     * @return bool
256
+     */
257
+    public function isDeletable($path) {
258
+        return $this->storage->isDeletable($this->findPathToUse($path));
259
+    }
260
+
261
+    /**
262
+     * check if a file can be shared
263
+     *
264
+     * @param string $path
265
+     * @return bool
266
+     */
267
+    public function isSharable($path) {
268
+        return $this->storage->isSharable($this->findPathToUse($path));
269
+    }
270
+
271
+    /**
272
+     * get the full permissions of a path.
273
+     * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
274
+     *
275
+     * @param string $path
276
+     * @return int
277
+     */
278
+    public function getPermissions($path) {
279
+        return $this->storage->getPermissions($this->findPathToUse($path));
280
+    }
281
+
282
+    /**
283
+     * see https://www.php.net/manual/en/function.file_exists.php
284
+     *
285
+     * @param string $path
286
+     * @return bool
287
+     */
288
+    public function file_exists($path) {
289
+        return $this->storage->file_exists($this->findPathToUse($path));
290
+    }
291
+
292
+    /**
293
+     * see https://www.php.net/manual/en/function.filemtime.php
294
+     *
295
+     * @param string $path
296
+     * @return int|bool
297
+     */
298
+    public function filemtime($path) {
299
+        return $this->storage->filemtime($this->findPathToUse($path));
300
+    }
301
+
302
+    /**
303
+     * see https://www.php.net/manual/en/function.file_get_contents.php
304
+     *
305
+     * @param string $path
306
+     * @return string|bool
307
+     */
308
+    public function file_get_contents($path) {
309
+        return $this->storage->file_get_contents($this->findPathToUse($path));
310
+    }
311
+
312
+    /**
313
+     * see https://www.php.net/manual/en/function.file_put_contents.php
314
+     *
315
+     * @param string $path
316
+     * @param mixed $data
317
+     * @return int|false
318
+     */
319
+    public function file_put_contents($path, $data) {
320
+        return $this->storage->file_put_contents($this->findPathToUse($path), $data);
321
+    }
322
+
323
+    /**
324
+     * see https://www.php.net/manual/en/function.unlink.php
325
+     *
326
+     * @param string $path
327
+     * @return bool
328
+     */
329
+    public function unlink($path) {
330
+        $result = $this->storage->unlink($this->findPathToUse($path));
331
+        if ($result) {
332
+            unset($this->namesCache[$path]);
333
+        }
334
+        return $result;
335
+    }
336
+
337
+    /**
338
+     * see https://www.php.net/manual/en/function.rename.php
339
+     *
340
+     * @param string $source
341
+     * @param string $target
342
+     * @return bool
343
+     */
344
+    public function rename($source, $target) {
345
+        // second name always NFC
346
+        return $this->storage->rename($this->findPathToUse($source), $this->findPathToUse($target));
347
+    }
348
+
349
+    /**
350
+     * see https://www.php.net/manual/en/function.copy.php
351
+     *
352
+     * @param string $source
353
+     * @param string $target
354
+     * @return bool
355
+     */
356
+    public function copy($source, $target) {
357
+        return $this->storage->copy($this->findPathToUse($source), $this->findPathToUse($target));
358
+    }
359
+
360
+    /**
361
+     * see https://www.php.net/manual/en/function.fopen.php
362
+     *
363
+     * @param string $path
364
+     * @param string $mode
365
+     * @return resource|bool
366
+     */
367
+    public function fopen($path, $mode) {
368
+        $result = $this->storage->fopen($this->findPathToUse($path), $mode);
369
+        if ($result && $mode !== 'r' && $mode !== 'rb') {
370
+            unset($this->namesCache[$path]);
371
+        }
372
+        return $result;
373
+    }
374
+
375
+    /**
376
+     * get the mimetype for a file or folder
377
+     * The mimetype for a folder is required to be "httpd/unix-directory"
378
+     *
379
+     * @param string $path
380
+     * @return string|bool
381
+     */
382
+    public function getMimeType($path) {
383
+        return $this->storage->getMimeType($this->findPathToUse($path));
384
+    }
385
+
386
+    /**
387
+     * see https://www.php.net/manual/en/function.hash.php
388
+     *
389
+     * @param string $type
390
+     * @param string $path
391
+     * @param bool $raw
392
+     * @return string|bool
393
+     */
394
+    public function hash($type, $path, $raw = false) {
395
+        return $this->storage->hash($type, $this->findPathToUse($path), $raw);
396
+    }
397
+
398
+    /**
399
+     * see https://www.php.net/manual/en/function.free_space.php
400
+     *
401
+     * @param string $path
402
+     * @return int|bool
403
+     */
404
+    public function free_space($path) {
405
+        return $this->storage->free_space($this->findPathToUse($path));
406
+    }
407
+
408
+    /**
409
+     * search for occurrences of $query in file names
410
+     *
411
+     * @param string $query
412
+     * @return array|bool
413
+     */
414
+    public function search($query) {
415
+        return $this->storage->search($query);
416
+    }
417
+
418
+    /**
419
+     * see https://www.php.net/manual/en/function.touch.php
420
+     * If the backend does not support the operation, false should be returned
421
+     *
422
+     * @param string $path
423
+     * @param int $mtime
424
+     * @return bool
425
+     */
426
+    public function touch($path, $mtime = null) {
427
+        return $this->storage->touch($this->findPathToUse($path), $mtime);
428
+    }
429
+
430
+    /**
431
+     * get the path to a local version of the file.
432
+     * The local version of the file can be temporary and doesn't have to be persistent across requests
433
+     *
434
+     * @param string $path
435
+     * @return string|bool
436
+     */
437
+    public function getLocalFile($path) {
438
+        return $this->storage->getLocalFile($this->findPathToUse($path));
439
+    }
440
+
441
+    /**
442
+     * check if a file or folder has been updated since $time
443
+     *
444
+     * @param string $path
445
+     * @param int $time
446
+     * @return bool
447
+     *
448
+     * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
449
+     * returning true for other changes in the folder is optional
450
+     */
451
+    public function hasUpdated($path, $time) {
452
+        return $this->storage->hasUpdated($this->findPathToUse($path), $time);
453
+    }
454
+
455
+    /**
456
+     * get a cache instance for the storage
457
+     *
458
+     * @param string $path
459
+     * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache
460
+     * @return \OC\Files\Cache\Cache
461
+     */
462
+    public function getCache($path = '', $storage = null) {
463
+        if (!$storage) {
464
+            $storage = $this;
465
+        }
466
+        return $this->storage->getCache($this->findPathToUse($path), $storage);
467
+    }
468
+
469
+    /**
470
+     * get a scanner instance for the storage
471
+     *
472
+     * @param string $path
473
+     * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
474
+     * @return \OC\Files\Cache\Scanner
475
+     */
476
+    public function getScanner($path = '', $storage = null) {
477
+        if (!$storage) {
478
+            $storage = $this;
479
+        }
480
+        return $this->storage->getScanner($this->findPathToUse($path), $storage);
481
+    }
482
+
483
+    /**
484
+     * get the ETag for a file or folder
485
+     *
486
+     * @param string $path
487
+     * @return string|bool
488
+     */
489
+    public function getETag($path) {
490
+        return $this->storage->getETag($this->findPathToUse($path));
491
+    }
492
+
493
+    /**
494
+     * @param IStorage $sourceStorage
495
+     * @param string $sourceInternalPath
496
+     * @param string $targetInternalPath
497
+     * @return bool
498
+     */
499
+    public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
500
+        if ($sourceStorage === $this) {
501
+            return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath));
502
+        }
503
+
504
+        $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath));
505
+        if ($result) {
506
+            unset($this->namesCache[$targetInternalPath]);
507
+        }
508
+        return $result;
509
+    }
510
+
511
+    /**
512
+     * @param IStorage $sourceStorage
513
+     * @param string $sourceInternalPath
514
+     * @param string $targetInternalPath
515
+     * @return bool
516
+     */
517
+    public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
518
+        if ($sourceStorage === $this) {
519
+            $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath));
520
+            if ($result) {
521
+                unset($this->namesCache[$sourceInternalPath]);
522
+                unset($this->namesCache[$targetInternalPath]);
523
+            }
524
+            return $result;
525
+        }
526
+
527
+        $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath));
528
+        if ($result) {
529
+            unset($this->namesCache[$sourceInternalPath]);
530
+            unset($this->namesCache[$targetInternalPath]);
531
+        }
532
+        return $result;
533
+    }
534
+
535
+    public function getMetaData($path) {
536
+        $entry = $this->storage->getMetaData($this->findPathToUse($path));
537
+        $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/');
538
+        return $entry;
539
+    }
540
+
541
+    public function getDirectoryContent($directory): \Traversable {
542
+        $entries = $this->storage->getDirectoryContent($this->findPathToUse($directory));
543
+        foreach ($entries as $entry) {
544
+            $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/');
545
+            yield $entry;
546
+        }
547
+    }
548 548
 }
Please login to merge, or discard this patch.
lib/private/Files/Storage/StorageFactory.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -29,80 +29,80 @@
 block discarded – undo
29 29
 use OCP\Files\Storage\IStorageFactory;
30 30
 
31 31
 class StorageFactory implements IStorageFactory {
32
-	/**
33
-	 * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers
34
-	 */
35
-	private $storageWrappers = [];
32
+    /**
33
+     * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers
34
+     */
35
+    private $storageWrappers = [];
36 36
 
37
-	/**
38
-	 * allow modifier storage behaviour by adding wrappers around storages
39
-	 *
40
-	 * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage
41
-	 *
42
-	 * @param string $wrapperName name of the wrapper
43
-	 * @param callable $callback callback
44
-	 * @param int $priority wrappers with the lower priority are applied last (meaning they get called first)
45
-	 * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to
46
-	 * @return bool true if the wrapper was added, false if there was already a wrapper with this
47
-	 * name registered
48
-	 */
49
-	public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) {
50
-		if (isset($this->storageWrappers[$wrapperName])) {
51
-			return false;
52
-		}
37
+    /**
38
+     * allow modifier storage behaviour by adding wrappers around storages
39
+     *
40
+     * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage
41
+     *
42
+     * @param string $wrapperName name of the wrapper
43
+     * @param callable $callback callback
44
+     * @param int $priority wrappers with the lower priority are applied last (meaning they get called first)
45
+     * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to
46
+     * @return bool true if the wrapper was added, false if there was already a wrapper with this
47
+     * name registered
48
+     */
49
+    public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) {
50
+        if (isset($this->storageWrappers[$wrapperName])) {
51
+            return false;
52
+        }
53 53
 
54
-		// apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage
55
-		foreach ($existingMounts as $mount) {
56
-			$mount->wrapStorage($callback);
57
-		}
54
+        // apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage
55
+        foreach ($existingMounts as $mount) {
56
+            $mount->wrapStorage($callback);
57
+        }
58 58
 
59
-		$this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority];
60
-		return true;
61
-	}
59
+        $this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority];
60
+        return true;
61
+    }
62 62
 
63
-	/**
64
-	 * Remove a storage wrapper by name.
65
-	 * Note: internal method only to be used for cleanup
66
-	 *
67
-	 * @param string $wrapperName name of the wrapper
68
-	 * @internal
69
-	 */
70
-	public function removeStorageWrapper($wrapperName) {
71
-		unset($this->storageWrappers[$wrapperName]);
72
-	}
63
+    /**
64
+     * Remove a storage wrapper by name.
65
+     * Note: internal method only to be used for cleanup
66
+     *
67
+     * @param string $wrapperName name of the wrapper
68
+     * @internal
69
+     */
70
+    public function removeStorageWrapper($wrapperName) {
71
+        unset($this->storageWrappers[$wrapperName]);
72
+    }
73 73
 
74
-	/**
75
-	 * Create an instance of a storage and apply the registered storage wrappers
76
-	 *
77
-	 * @param \OCP\Files\Mount\IMountPoint $mountPoint
78
-	 * @param string $class
79
-	 * @param array $arguments
80
-	 * @return \OCP\Files\Storage
81
-	 */
82
-	public function getInstance(IMountPoint $mountPoint, $class, $arguments) {
83
-		return $this->wrap($mountPoint, new $class($arguments));
84
-	}
74
+    /**
75
+     * Create an instance of a storage and apply the registered storage wrappers
76
+     *
77
+     * @param \OCP\Files\Mount\IMountPoint $mountPoint
78
+     * @param string $class
79
+     * @param array $arguments
80
+     * @return \OCP\Files\Storage
81
+     */
82
+    public function getInstance(IMountPoint $mountPoint, $class, $arguments) {
83
+        return $this->wrap($mountPoint, new $class($arguments));
84
+    }
85 85
 
86
-	/**
87
-	 * @param \OCP\Files\Mount\IMountPoint $mountPoint
88
-	 * @param \OCP\Files\Storage $storage
89
-	 * @return \OCP\Files\Storage
90
-	 */
91
-	public function wrap(IMountPoint $mountPoint, $storage) {
92
-		$wrappers = array_values($this->storageWrappers);
93
-		usort($wrappers, function ($a, $b) {
94
-			return $b['priority'] - $a['priority'];
95
-		});
96
-		/** @var callable[] $wrappers */
97
-		$wrappers = array_map(function ($wrapper) {
98
-			return $wrapper['wrapper'];
99
-		}, $wrappers);
100
-		foreach ($wrappers as $wrapper) {
101
-			$storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint);
102
-			if (!($storage instanceof \OCP\Files\Storage)) {
103
-				throw new \Exception('Invalid result from storage wrapper');
104
-			}
105
-		}
106
-		return $storage;
107
-	}
86
+    /**
87
+     * @param \OCP\Files\Mount\IMountPoint $mountPoint
88
+     * @param \OCP\Files\Storage $storage
89
+     * @return \OCP\Files\Storage
90
+     */
91
+    public function wrap(IMountPoint $mountPoint, $storage) {
92
+        $wrappers = array_values($this->storageWrappers);
93
+        usort($wrappers, function ($a, $b) {
94
+            return $b['priority'] - $a['priority'];
95
+        });
96
+        /** @var callable[] $wrappers */
97
+        $wrappers = array_map(function ($wrapper) {
98
+            return $wrapper['wrapper'];
99
+        }, $wrappers);
100
+        foreach ($wrappers as $wrapper) {
101
+            $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint);
102
+            if (!($storage instanceof \OCP\Files\Storage)) {
103
+                throw new \Exception('Invalid result from storage wrapper');
104
+            }
105
+        }
106
+        return $storage;
107
+    }
108 108
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,11 +90,11 @@
 block discarded – undo
90 90
 	 */
91 91
 	public function wrap(IMountPoint $mountPoint, $storage) {
92 92
 		$wrappers = array_values($this->storageWrappers);
93
-		usort($wrappers, function ($a, $b) {
93
+		usort($wrappers, function($a, $b) {
94 94
 			return $b['priority'] - $a['priority'];
95 95
 		});
96 96
 		/** @var callable[] $wrappers */
97
-		$wrappers = array_map(function ($wrapper) {
97
+		$wrappers = array_map(function($wrapper) {
98 98
 			return $wrapper['wrapper'];
99 99
 		}, $wrappers);
100 100
 		foreach ($wrappers as $wrapper) {
Please login to merge, or discard this patch.
lib/private/Files/Storage/PolyFill/CopyDirectory.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -25,81 +25,81 @@
 block discarded – undo
25 25
 namespace OC\Files\Storage\PolyFill;
26 26
 
27 27
 trait CopyDirectory {
28
-	/**
29
-	 * Check if a path is a directory
30
-	 *
31
-	 * @param string $path
32
-	 * @return bool
33
-	 */
34
-	abstract public function is_dir($path);
28
+    /**
29
+     * Check if a path is a directory
30
+     *
31
+     * @param string $path
32
+     * @return bool
33
+     */
34
+    abstract public function is_dir($path);
35 35
 
36
-	/**
37
-	 * Check if a file or folder exists
38
-	 *
39
-	 * @param string $path
40
-	 * @return bool
41
-	 */
42
-	abstract public function file_exists($path);
36
+    /**
37
+     * Check if a file or folder exists
38
+     *
39
+     * @param string $path
40
+     * @return bool
41
+     */
42
+    abstract public function file_exists($path);
43 43
 
44
-	/**
45
-	 * Delete a file or folder
46
-	 *
47
-	 * @param string $path
48
-	 * @return bool
49
-	 */
50
-	abstract public function unlink($path);
44
+    /**
45
+     * Delete a file or folder
46
+     *
47
+     * @param string $path
48
+     * @return bool
49
+     */
50
+    abstract public function unlink($path);
51 51
 
52
-	/**
53
-	 * Open a directory handle for a folder
54
-	 *
55
-	 * @param string $path
56
-	 * @return resource | bool
57
-	 */
58
-	abstract public function opendir($path);
52
+    /**
53
+     * Open a directory handle for a folder
54
+     *
55
+     * @param string $path
56
+     * @return resource | bool
57
+     */
58
+    abstract public function opendir($path);
59 59
 
60
-	/**
61
-	 * Create a new folder
62
-	 *
63
-	 * @param string $path
64
-	 * @return bool
65
-	 */
66
-	abstract public function mkdir($path);
60
+    /**
61
+     * Create a new folder
62
+     *
63
+     * @param string $path
64
+     * @return bool
65
+     */
66
+    abstract public function mkdir($path);
67 67
 
68
-	public function copy($source, $target) {
69
-		if ($this->is_dir($source)) {
70
-			if ($this->file_exists($target)) {
71
-				$this->unlink($target);
72
-			}
73
-			$this->mkdir($target);
74
-			return $this->copyRecursive($source, $target);
75
-		} else {
76
-			return parent::copy($source, $target);
77
-		}
78
-	}
68
+    public function copy($source, $target) {
69
+        if ($this->is_dir($source)) {
70
+            if ($this->file_exists($target)) {
71
+                $this->unlink($target);
72
+            }
73
+            $this->mkdir($target);
74
+            return $this->copyRecursive($source, $target);
75
+        } else {
76
+            return parent::copy($source, $target);
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * For adapters that don't support copying folders natively
82
-	 *
83
-	 * @param $source
84
-	 * @param $target
85
-	 * @return bool
86
-	 */
87
-	protected function copyRecursive($source, $target) {
88
-		$dh = $this->opendir($source);
89
-		$result = true;
90
-		while ($file = readdir($dh)) {
91
-			if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
92
-				if ($this->is_dir($source . '/' . $file)) {
93
-					$this->mkdir($target . '/' . $file);
94
-					$result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
95
-				} else {
96
-					$result = parent::copy($source . '/' . $file, $target . '/' . $file);
97
-				}
98
-				if (!$result) {
99
-					break;
100
-				}
101
-			}
102
-		}
103
-		return $result;
104
-	}
80
+    /**
81
+     * For adapters that don't support copying folders natively
82
+     *
83
+     * @param $source
84
+     * @param $target
85
+     * @return bool
86
+     */
87
+    protected function copyRecursive($source, $target) {
88
+        $dh = $this->opendir($source);
89
+        $result = true;
90
+        while ($file = readdir($dh)) {
91
+            if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
92
+                if ($this->is_dir($source . '/' . $file)) {
93
+                    $this->mkdir($target . '/' . $file);
94
+                    $result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
95
+                } else {
96
+                    $result = parent::copy($source . '/' . $file, $target . '/' . $file);
97
+                }
98
+                if (!$result) {
99
+                    break;
100
+                }
101
+            }
102
+        }
103
+        return $result;
104
+    }
105 105
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -89,11 +89,11 @@
 block discarded – undo
89 89
 		$result = true;
90 90
 		while ($file = readdir($dh)) {
91 91
 			if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
92
-				if ($this->is_dir($source . '/' . $file)) {
93
-					$this->mkdir($target . '/' . $file);
94
-					$result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file);
92
+				if ($this->is_dir($source.'/'.$file)) {
93
+					$this->mkdir($target.'/'.$file);
94
+					$result = $this->copyRecursive($source.'/'.$file, $target.'/'.$file);
95 95
 				} else {
96
-					$result = parent::copy($source . '/' . $file, $target . '/' . $file);
96
+					$result = parent::copy($source.'/'.$file, $target.'/'.$file);
97 97
 				}
98 98
 				if (!$result) {
99 99
 					break;
Please login to merge, or discard this patch.
lib/private/Files/Notify/RenameChange.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@
 block discarded – undo
26 26
 use OCP\Files\Notify\IRenameChange;
27 27
 
28 28
 class RenameChange extends Change implements IRenameChange {
29
-	/** @var string */
30
-	private $targetPath;
29
+    /** @var string */
30
+    private $targetPath;
31 31
 
32
-	/**
33
-	 * Change constructor.
34
-	 *
35
-	 * @param int $type
36
-	 * @param string $path
37
-	 * @param string $targetPath
38
-	 */
39
-	public function __construct($type, $path, $targetPath) {
40
-		parent::__construct($type, $path);
41
-		$this->targetPath = $targetPath;
42
-	}
32
+    /**
33
+     * Change constructor.
34
+     *
35
+     * @param int $type
36
+     * @param string $path
37
+     * @param string $targetPath
38
+     */
39
+    public function __construct($type, $path, $targetPath) {
40
+        parent::__construct($type, $path);
41
+        $this->targetPath = $targetPath;
42
+    }
43 43
 
44
-	/**
45
-	 * Get the new path of the renamed file relative to the storage root
46
-	 *
47
-	 * @return string
48
-	 */
49
-	public function getTargetPath() {
50
-		return $this->targetPath;
51
-	}
44
+    /**
45
+     * Get the new path of the renamed file relative to the storage root
46
+     *
47
+     * @return string
48
+     */
49
+    public function getTargetPath() {
50
+        return $this->targetPath;
51
+    }
52 52
 }
Please login to merge, or discard this patch.