@@ -31,25 +31,25 @@ |
||
31 | 31 | * Map a user to a bucket. |
32 | 32 | */ |
33 | 33 | class Mapper { |
34 | - /** @var IUser */ |
|
35 | - private $user; |
|
34 | + /** @var IUser */ |
|
35 | + private $user; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Mapper constructor. |
|
39 | - * |
|
40 | - * @param IUser $user |
|
41 | - */ |
|
42 | - public function __construct(IUser $user) { |
|
43 | - $this->user = $user; |
|
44 | - } |
|
37 | + /** |
|
38 | + * Mapper constructor. |
|
39 | + * |
|
40 | + * @param IUser $user |
|
41 | + */ |
|
42 | + public function __construct(IUser $user) { |
|
43 | + $this->user = $user; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param int $numBuckets |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getBucket($numBuckets = 64) { |
|
51 | - $hash = md5($this->user->getUID()); |
|
52 | - $num = hexdec(substr($hash, 0, 4)); |
|
53 | - return (string)($num % $numBuckets); |
|
54 | - } |
|
46 | + /** |
|
47 | + * @param int $numBuckets |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getBucket($numBuckets = 64) { |
|
51 | + $hash = md5($this->user->getUID()); |
|
52 | + $num = hexdec(substr($hash, 0, 4)); |
|
53 | + return (string)($num % $numBuckets); |
|
54 | + } |
|
55 | 55 | } |
@@ -50,6 +50,6 @@ |
||
50 | 50 | public function getBucket($numBuckets = 64) { |
51 | 51 | $hash = md5($this->user->getUID()); |
52 | 52 | $num = hexdec(substr($hash, 0, 4)); |
53 | - return (string)($num % $numBuckets); |
|
53 | + return (string) ($num % $numBuckets); |
|
54 | 54 | } |
55 | 55 | } |
@@ -80,7 +80,7 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -36,506 +36,506 @@ |
||
36 | 36 | */ |
37 | 37 | class Encoding extends Wrapper { |
38 | 38 | |
39 | - /** |
|
40 | - * @var ICache |
|
41 | - */ |
|
42 | - private $namesCache; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param array $parameters |
|
46 | - */ |
|
47 | - public function __construct($parameters) { |
|
48 | - $this->storage = $parameters['storage']; |
|
49 | - $this->namesCache = new CappedMemoryCache(); |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Returns whether the given string is only made of ASCII characters |
|
54 | - * |
|
55 | - * @param string $str string |
|
56 | - * |
|
57 | - * @return bool true if the string is all ASCII, false otherwise |
|
58 | - */ |
|
59 | - private function isAscii($str) { |
|
60 | - return (bool) !preg_match('/[\\x80-\\xff]+/', $str); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Checks whether the given path exists in NFC or NFD form after checking |
|
65 | - * each form for each path section and returns the correct form. |
|
66 | - * If no existing path found, returns the path as it was given. |
|
67 | - * |
|
68 | - * @param string $fullPath path to check |
|
69 | - * |
|
70 | - * @return string original or converted path |
|
71 | - */ |
|
72 | - private function findPathToUse($fullPath) { |
|
73 | - $cachedPath = $this->namesCache[$fullPath]; |
|
74 | - if ($cachedPath !== null) { |
|
75 | - return $cachedPath; |
|
76 | - } |
|
77 | - |
|
78 | - $sections = explode('/', $fullPath); |
|
79 | - $path = ''; |
|
80 | - foreach ($sections as $section) { |
|
81 | - $convertedPath = $this->findPathToUseLastSection($path, $section); |
|
82 | - if ($convertedPath === null) { |
|
83 | - // no point in continuing if the section was not found, use original path |
|
84 | - return $fullPath; |
|
85 | - } |
|
86 | - $path = $convertedPath . '/'; |
|
87 | - } |
|
88 | - $path = rtrim($path, '/'); |
|
89 | - return $path; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Checks whether the last path section of the given path exists in NFC or NFD form |
|
94 | - * and returns the correct form. If no existing path found, returns null. |
|
95 | - * |
|
96 | - * @param string $basePath base path to check |
|
97 | - * @param string $lastSection last section of the path to check for NFD/NFC variations |
|
98 | - * |
|
99 | - * @return string|null original or converted path, or null if none of the forms was found |
|
100 | - */ |
|
101 | - private function findPathToUseLastSection($basePath, $lastSection) { |
|
102 | - $fullPath = $basePath . $lastSection; |
|
103 | - if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { |
|
104 | - $this->namesCache[$fullPath] = $fullPath; |
|
105 | - return $fullPath; |
|
106 | - } |
|
107 | - |
|
108 | - // swap encoding |
|
109 | - if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) { |
|
110 | - $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D); |
|
111 | - } else { |
|
112 | - $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); |
|
113 | - } |
|
114 | - $otherFullPath = $basePath . $otherFormPath; |
|
115 | - if ($this->storage->file_exists($otherFullPath)) { |
|
116 | - $this->namesCache[$fullPath] = $otherFullPath; |
|
117 | - return $otherFullPath; |
|
118 | - } |
|
119 | - |
|
120 | - // return original path, file did not exist at all |
|
121 | - $this->namesCache[$fullPath] = $fullPath; |
|
122 | - return null; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * see http://php.net/manual/en/function.mkdir.php |
|
127 | - * |
|
128 | - * @param string $path |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - public function mkdir($path) { |
|
132 | - // note: no conversion here, method should not be called with non-NFC names! |
|
133 | - $result = $this->storage->mkdir($path); |
|
134 | - if ($result) { |
|
135 | - $this->namesCache[$path] = $path; |
|
136 | - } |
|
137 | - return $result; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * see http://php.net/manual/en/function.rmdir.php |
|
142 | - * |
|
143 | - * @param string $path |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function rmdir($path) { |
|
147 | - $result = $this->storage->rmdir($this->findPathToUse($path)); |
|
148 | - if ($result) { |
|
149 | - unset($this->namesCache[$path]); |
|
150 | - } |
|
151 | - return $result; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * see http://php.net/manual/en/function.opendir.php |
|
156 | - * |
|
157 | - * @param string $path |
|
158 | - * @return resource |
|
159 | - */ |
|
160 | - public function opendir($path) { |
|
161 | - return $this->storage->opendir($this->findPathToUse($path)); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * see http://php.net/manual/en/function.is_dir.php |
|
166 | - * |
|
167 | - * @param string $path |
|
168 | - * @return bool |
|
169 | - */ |
|
170 | - public function is_dir($path) { |
|
171 | - return $this->storage->is_dir($this->findPathToUse($path)); |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * see http://php.net/manual/en/function.is_file.php |
|
176 | - * |
|
177 | - * @param string $path |
|
178 | - * @return bool |
|
179 | - */ |
|
180 | - public function is_file($path) { |
|
181 | - return $this->storage->is_file($this->findPathToUse($path)); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * see http://php.net/manual/en/function.stat.php |
|
186 | - * only the following keys are required in the result: size and mtime |
|
187 | - * |
|
188 | - * @param string $path |
|
189 | - * @return array |
|
190 | - */ |
|
191 | - public function stat($path) { |
|
192 | - return $this->storage->stat($this->findPathToUse($path)); |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * see http://php.net/manual/en/function.filetype.php |
|
197 | - * |
|
198 | - * @param string $path |
|
199 | - * @return bool |
|
200 | - */ |
|
201 | - public function filetype($path) { |
|
202 | - return $this->storage->filetype($this->findPathToUse($path)); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * see http://php.net/manual/en/function.filesize.php |
|
207 | - * The result for filesize when called on a folder is required to be 0 |
|
208 | - * |
|
209 | - * @param string $path |
|
210 | - * @return int |
|
211 | - */ |
|
212 | - public function filesize($path) { |
|
213 | - return $this->storage->filesize($this->findPathToUse($path)); |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * check if a file can be created in $path |
|
218 | - * |
|
219 | - * @param string $path |
|
220 | - * @return bool |
|
221 | - */ |
|
222 | - public function isCreatable($path) { |
|
223 | - return $this->storage->isCreatable($this->findPathToUse($path)); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * check if a file can be read |
|
228 | - * |
|
229 | - * @param string $path |
|
230 | - * @return bool |
|
231 | - */ |
|
232 | - public function isReadable($path) { |
|
233 | - return $this->storage->isReadable($this->findPathToUse($path)); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * check if a file can be written to |
|
238 | - * |
|
239 | - * @param string $path |
|
240 | - * @return bool |
|
241 | - */ |
|
242 | - public function isUpdatable($path) { |
|
243 | - return $this->storage->isUpdatable($this->findPathToUse($path)); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * check if a file can be deleted |
|
248 | - * |
|
249 | - * @param string $path |
|
250 | - * @return bool |
|
251 | - */ |
|
252 | - public function isDeletable($path) { |
|
253 | - return $this->storage->isDeletable($this->findPathToUse($path)); |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * check if a file can be shared |
|
258 | - * |
|
259 | - * @param string $path |
|
260 | - * @return bool |
|
261 | - */ |
|
262 | - public function isSharable($path) { |
|
263 | - return $this->storage->isSharable($this->findPathToUse($path)); |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * get the full permissions of a path. |
|
268 | - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
269 | - * |
|
270 | - * @param string $path |
|
271 | - * @return int |
|
272 | - */ |
|
273 | - public function getPermissions($path) { |
|
274 | - return $this->storage->getPermissions($this->findPathToUse($path)); |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * see http://php.net/manual/en/function.file_exists.php |
|
279 | - * |
|
280 | - * @param string $path |
|
281 | - * @return bool |
|
282 | - */ |
|
283 | - public function file_exists($path) { |
|
284 | - return $this->storage->file_exists($this->findPathToUse($path)); |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * see http://php.net/manual/en/function.filemtime.php |
|
289 | - * |
|
290 | - * @param string $path |
|
291 | - * @return int |
|
292 | - */ |
|
293 | - public function filemtime($path) { |
|
294 | - return $this->storage->filemtime($this->findPathToUse($path)); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * see http://php.net/manual/en/function.file_get_contents.php |
|
299 | - * |
|
300 | - * @param string $path |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - public function file_get_contents($path) { |
|
304 | - return $this->storage->file_get_contents($this->findPathToUse($path)); |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * see http://php.net/manual/en/function.file_put_contents.php |
|
309 | - * |
|
310 | - * @param string $path |
|
311 | - * @param string $data |
|
312 | - * @return bool |
|
313 | - */ |
|
314 | - public function file_put_contents($path, $data) { |
|
315 | - return $this->storage->file_put_contents($this->findPathToUse($path), $data); |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * see http://php.net/manual/en/function.unlink.php |
|
320 | - * |
|
321 | - * @param string $path |
|
322 | - * @return bool |
|
323 | - */ |
|
324 | - public function unlink($path) { |
|
325 | - $result = $this->storage->unlink($this->findPathToUse($path)); |
|
326 | - if ($result) { |
|
327 | - unset($this->namesCache[$path]); |
|
328 | - } |
|
329 | - return $result; |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * see http://php.net/manual/en/function.rename.php |
|
334 | - * |
|
335 | - * @param string $path1 |
|
336 | - * @param string $path2 |
|
337 | - * @return bool |
|
338 | - */ |
|
339 | - public function rename($path1, $path2) { |
|
340 | - // second name always NFC |
|
341 | - return $this->storage->rename($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * see http://php.net/manual/en/function.copy.php |
|
346 | - * |
|
347 | - * @param string $path1 |
|
348 | - * @param string $path2 |
|
349 | - * @return bool |
|
350 | - */ |
|
351 | - public function copy($path1, $path2) { |
|
352 | - return $this->storage->copy($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * see http://php.net/manual/en/function.fopen.php |
|
357 | - * |
|
358 | - * @param string $path |
|
359 | - * @param string $mode |
|
360 | - * @return resource |
|
361 | - */ |
|
362 | - public function fopen($path, $mode) { |
|
363 | - $result = $this->storage->fopen($this->findPathToUse($path), $mode); |
|
364 | - if ($result && $mode !== 'r' && $mode !== 'rb') { |
|
365 | - unset($this->namesCache[$path]); |
|
366 | - } |
|
367 | - return $result; |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * get the mimetype for a file or folder |
|
372 | - * The mimetype for a folder is required to be "httpd/unix-directory" |
|
373 | - * |
|
374 | - * @param string $path |
|
375 | - * @return string |
|
376 | - */ |
|
377 | - public function getMimeType($path) { |
|
378 | - return $this->storage->getMimeType($this->findPathToUse($path)); |
|
379 | - } |
|
380 | - |
|
381 | - /** |
|
382 | - * see http://php.net/manual/en/function.hash.php |
|
383 | - * |
|
384 | - * @param string $type |
|
385 | - * @param string $path |
|
386 | - * @param bool $raw |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function hash($type, $path, $raw = false) { |
|
390 | - return $this->storage->hash($type, $this->findPathToUse($path), $raw); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * see http://php.net/manual/en/function.free_space.php |
|
395 | - * |
|
396 | - * @param string $path |
|
397 | - * @return int |
|
398 | - */ |
|
399 | - public function free_space($path) { |
|
400 | - return $this->storage->free_space($this->findPathToUse($path)); |
|
401 | - } |
|
402 | - |
|
403 | - /** |
|
404 | - * search for occurrences of $query in file names |
|
405 | - * |
|
406 | - * @param string $query |
|
407 | - * @return array |
|
408 | - */ |
|
409 | - public function search($query) { |
|
410 | - return $this->storage->search($query); |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * see http://php.net/manual/en/function.touch.php |
|
415 | - * If the backend does not support the operation, false should be returned |
|
416 | - * |
|
417 | - * @param string $path |
|
418 | - * @param int $mtime |
|
419 | - * @return bool |
|
420 | - */ |
|
421 | - public function touch($path, $mtime = null) { |
|
422 | - return $this->storage->touch($this->findPathToUse($path), $mtime); |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * get the path to a local version of the file. |
|
427 | - * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
428 | - * |
|
429 | - * @param string $path |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - public function getLocalFile($path) { |
|
433 | - return $this->storage->getLocalFile($this->findPathToUse($path)); |
|
434 | - } |
|
435 | - |
|
436 | - /** |
|
437 | - * check if a file or folder has been updated since $time |
|
438 | - * |
|
439 | - * @param string $path |
|
440 | - * @param int $time |
|
441 | - * @return bool |
|
442 | - * |
|
443 | - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
444 | - * returning true for other changes in the folder is optional |
|
445 | - */ |
|
446 | - public function hasUpdated($path, $time) { |
|
447 | - return $this->storage->hasUpdated($this->findPathToUse($path), $time); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * get a cache instance for the storage |
|
452 | - * |
|
453 | - * @param string $path |
|
454 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
455 | - * @return \OC\Files\Cache\Cache |
|
456 | - */ |
|
457 | - public function getCache($path = '', $storage = null) { |
|
458 | - if (!$storage) { |
|
459 | - $storage = $this; |
|
460 | - } |
|
461 | - return $this->storage->getCache($this->findPathToUse($path), $storage); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * get a scanner instance for the storage |
|
466 | - * |
|
467 | - * @param string $path |
|
468 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
469 | - * @return \OC\Files\Cache\Scanner |
|
470 | - */ |
|
471 | - public function getScanner($path = '', $storage = null) { |
|
472 | - if (!$storage) { |
|
473 | - $storage = $this; |
|
474 | - } |
|
475 | - return $this->storage->getScanner($this->findPathToUse($path), $storage); |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * get the ETag for a file or folder |
|
480 | - * |
|
481 | - * @param string $path |
|
482 | - * @return string |
|
483 | - */ |
|
484 | - public function getETag($path) { |
|
485 | - return $this->storage->getETag($this->findPathToUse($path)); |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * @param IStorage $sourceStorage |
|
490 | - * @param string $sourceInternalPath |
|
491 | - * @param string $targetInternalPath |
|
492 | - * @return bool |
|
493 | - */ |
|
494 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
495 | - if ($sourceStorage === $this) { |
|
496 | - return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
497 | - } |
|
498 | - |
|
499 | - $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
500 | - if ($result) { |
|
501 | - unset($this->namesCache[$targetInternalPath]); |
|
502 | - } |
|
503 | - return $result; |
|
504 | - } |
|
505 | - |
|
506 | - /** |
|
507 | - * @param IStorage $sourceStorage |
|
508 | - * @param string $sourceInternalPath |
|
509 | - * @param string $targetInternalPath |
|
510 | - * @return bool |
|
511 | - */ |
|
512 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
513 | - if ($sourceStorage === $this) { |
|
514 | - $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
515 | - if ($result) { |
|
516 | - unset($this->namesCache[$sourceInternalPath]); |
|
517 | - unset($this->namesCache[$targetInternalPath]); |
|
518 | - } |
|
519 | - return $result; |
|
520 | - } |
|
521 | - |
|
522 | - $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
523 | - if ($result) { |
|
524 | - unset($this->namesCache[$sourceInternalPath]); |
|
525 | - unset($this->namesCache[$targetInternalPath]); |
|
526 | - } |
|
527 | - return $result; |
|
528 | - } |
|
529 | - |
|
530 | - /** |
|
531 | - * @param string $path |
|
532 | - * @return array |
|
533 | - */ |
|
534 | - public function getMetaData($path) { |
|
535 | - return $this->storage->getMetaData($this->findPathToUse($path)); |
|
536 | - } |
|
537 | - |
|
538 | - public function getDirectoryContent($directory): \Traversable { |
|
539 | - return $this->storage->getDirectoryContent($this->findPathToUse($directory)); |
|
540 | - } |
|
39 | + /** |
|
40 | + * @var ICache |
|
41 | + */ |
|
42 | + private $namesCache; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param array $parameters |
|
46 | + */ |
|
47 | + public function __construct($parameters) { |
|
48 | + $this->storage = $parameters['storage']; |
|
49 | + $this->namesCache = new CappedMemoryCache(); |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Returns whether the given string is only made of ASCII characters |
|
54 | + * |
|
55 | + * @param string $str string |
|
56 | + * |
|
57 | + * @return bool true if the string is all ASCII, false otherwise |
|
58 | + */ |
|
59 | + private function isAscii($str) { |
|
60 | + return (bool) !preg_match('/[\\x80-\\xff]+/', $str); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Checks whether the given path exists in NFC or NFD form after checking |
|
65 | + * each form for each path section and returns the correct form. |
|
66 | + * If no existing path found, returns the path as it was given. |
|
67 | + * |
|
68 | + * @param string $fullPath path to check |
|
69 | + * |
|
70 | + * @return string original or converted path |
|
71 | + */ |
|
72 | + private function findPathToUse($fullPath) { |
|
73 | + $cachedPath = $this->namesCache[$fullPath]; |
|
74 | + if ($cachedPath !== null) { |
|
75 | + return $cachedPath; |
|
76 | + } |
|
77 | + |
|
78 | + $sections = explode('/', $fullPath); |
|
79 | + $path = ''; |
|
80 | + foreach ($sections as $section) { |
|
81 | + $convertedPath = $this->findPathToUseLastSection($path, $section); |
|
82 | + if ($convertedPath === null) { |
|
83 | + // no point in continuing if the section was not found, use original path |
|
84 | + return $fullPath; |
|
85 | + } |
|
86 | + $path = $convertedPath . '/'; |
|
87 | + } |
|
88 | + $path = rtrim($path, '/'); |
|
89 | + return $path; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Checks whether the last path section of the given path exists in NFC or NFD form |
|
94 | + * and returns the correct form. If no existing path found, returns null. |
|
95 | + * |
|
96 | + * @param string $basePath base path to check |
|
97 | + * @param string $lastSection last section of the path to check for NFD/NFC variations |
|
98 | + * |
|
99 | + * @return string|null original or converted path, or null if none of the forms was found |
|
100 | + */ |
|
101 | + private function findPathToUseLastSection($basePath, $lastSection) { |
|
102 | + $fullPath = $basePath . $lastSection; |
|
103 | + if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { |
|
104 | + $this->namesCache[$fullPath] = $fullPath; |
|
105 | + return $fullPath; |
|
106 | + } |
|
107 | + |
|
108 | + // swap encoding |
|
109 | + if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) { |
|
110 | + $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D); |
|
111 | + } else { |
|
112 | + $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); |
|
113 | + } |
|
114 | + $otherFullPath = $basePath . $otherFormPath; |
|
115 | + if ($this->storage->file_exists($otherFullPath)) { |
|
116 | + $this->namesCache[$fullPath] = $otherFullPath; |
|
117 | + return $otherFullPath; |
|
118 | + } |
|
119 | + |
|
120 | + // return original path, file did not exist at all |
|
121 | + $this->namesCache[$fullPath] = $fullPath; |
|
122 | + return null; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * see http://php.net/manual/en/function.mkdir.php |
|
127 | + * |
|
128 | + * @param string $path |
|
129 | + * @return bool |
|
130 | + */ |
|
131 | + public function mkdir($path) { |
|
132 | + // note: no conversion here, method should not be called with non-NFC names! |
|
133 | + $result = $this->storage->mkdir($path); |
|
134 | + if ($result) { |
|
135 | + $this->namesCache[$path] = $path; |
|
136 | + } |
|
137 | + return $result; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * see http://php.net/manual/en/function.rmdir.php |
|
142 | + * |
|
143 | + * @param string $path |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function rmdir($path) { |
|
147 | + $result = $this->storage->rmdir($this->findPathToUse($path)); |
|
148 | + if ($result) { |
|
149 | + unset($this->namesCache[$path]); |
|
150 | + } |
|
151 | + return $result; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * see http://php.net/manual/en/function.opendir.php |
|
156 | + * |
|
157 | + * @param string $path |
|
158 | + * @return resource |
|
159 | + */ |
|
160 | + public function opendir($path) { |
|
161 | + return $this->storage->opendir($this->findPathToUse($path)); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * see http://php.net/manual/en/function.is_dir.php |
|
166 | + * |
|
167 | + * @param string $path |
|
168 | + * @return bool |
|
169 | + */ |
|
170 | + public function is_dir($path) { |
|
171 | + return $this->storage->is_dir($this->findPathToUse($path)); |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * see http://php.net/manual/en/function.is_file.php |
|
176 | + * |
|
177 | + * @param string $path |
|
178 | + * @return bool |
|
179 | + */ |
|
180 | + public function is_file($path) { |
|
181 | + return $this->storage->is_file($this->findPathToUse($path)); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * see http://php.net/manual/en/function.stat.php |
|
186 | + * only the following keys are required in the result: size and mtime |
|
187 | + * |
|
188 | + * @param string $path |
|
189 | + * @return array |
|
190 | + */ |
|
191 | + public function stat($path) { |
|
192 | + return $this->storage->stat($this->findPathToUse($path)); |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * see http://php.net/manual/en/function.filetype.php |
|
197 | + * |
|
198 | + * @param string $path |
|
199 | + * @return bool |
|
200 | + */ |
|
201 | + public function filetype($path) { |
|
202 | + return $this->storage->filetype($this->findPathToUse($path)); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * see http://php.net/manual/en/function.filesize.php |
|
207 | + * The result for filesize when called on a folder is required to be 0 |
|
208 | + * |
|
209 | + * @param string $path |
|
210 | + * @return int |
|
211 | + */ |
|
212 | + public function filesize($path) { |
|
213 | + return $this->storage->filesize($this->findPathToUse($path)); |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * check if a file can be created in $path |
|
218 | + * |
|
219 | + * @param string $path |
|
220 | + * @return bool |
|
221 | + */ |
|
222 | + public function isCreatable($path) { |
|
223 | + return $this->storage->isCreatable($this->findPathToUse($path)); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * check if a file can be read |
|
228 | + * |
|
229 | + * @param string $path |
|
230 | + * @return bool |
|
231 | + */ |
|
232 | + public function isReadable($path) { |
|
233 | + return $this->storage->isReadable($this->findPathToUse($path)); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * check if a file can be written to |
|
238 | + * |
|
239 | + * @param string $path |
|
240 | + * @return bool |
|
241 | + */ |
|
242 | + public function isUpdatable($path) { |
|
243 | + return $this->storage->isUpdatable($this->findPathToUse($path)); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * check if a file can be deleted |
|
248 | + * |
|
249 | + * @param string $path |
|
250 | + * @return bool |
|
251 | + */ |
|
252 | + public function isDeletable($path) { |
|
253 | + return $this->storage->isDeletable($this->findPathToUse($path)); |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * check if a file can be shared |
|
258 | + * |
|
259 | + * @param string $path |
|
260 | + * @return bool |
|
261 | + */ |
|
262 | + public function isSharable($path) { |
|
263 | + return $this->storage->isSharable($this->findPathToUse($path)); |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * get the full permissions of a path. |
|
268 | + * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
269 | + * |
|
270 | + * @param string $path |
|
271 | + * @return int |
|
272 | + */ |
|
273 | + public function getPermissions($path) { |
|
274 | + return $this->storage->getPermissions($this->findPathToUse($path)); |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * see http://php.net/manual/en/function.file_exists.php |
|
279 | + * |
|
280 | + * @param string $path |
|
281 | + * @return bool |
|
282 | + */ |
|
283 | + public function file_exists($path) { |
|
284 | + return $this->storage->file_exists($this->findPathToUse($path)); |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * see http://php.net/manual/en/function.filemtime.php |
|
289 | + * |
|
290 | + * @param string $path |
|
291 | + * @return int |
|
292 | + */ |
|
293 | + public function filemtime($path) { |
|
294 | + return $this->storage->filemtime($this->findPathToUse($path)); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * see http://php.net/manual/en/function.file_get_contents.php |
|
299 | + * |
|
300 | + * @param string $path |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + public function file_get_contents($path) { |
|
304 | + return $this->storage->file_get_contents($this->findPathToUse($path)); |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * see http://php.net/manual/en/function.file_put_contents.php |
|
309 | + * |
|
310 | + * @param string $path |
|
311 | + * @param string $data |
|
312 | + * @return bool |
|
313 | + */ |
|
314 | + public function file_put_contents($path, $data) { |
|
315 | + return $this->storage->file_put_contents($this->findPathToUse($path), $data); |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * see http://php.net/manual/en/function.unlink.php |
|
320 | + * |
|
321 | + * @param string $path |
|
322 | + * @return bool |
|
323 | + */ |
|
324 | + public function unlink($path) { |
|
325 | + $result = $this->storage->unlink($this->findPathToUse($path)); |
|
326 | + if ($result) { |
|
327 | + unset($this->namesCache[$path]); |
|
328 | + } |
|
329 | + return $result; |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * see http://php.net/manual/en/function.rename.php |
|
334 | + * |
|
335 | + * @param string $path1 |
|
336 | + * @param string $path2 |
|
337 | + * @return bool |
|
338 | + */ |
|
339 | + public function rename($path1, $path2) { |
|
340 | + // second name always NFC |
|
341 | + return $this->storage->rename($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * see http://php.net/manual/en/function.copy.php |
|
346 | + * |
|
347 | + * @param string $path1 |
|
348 | + * @param string $path2 |
|
349 | + * @return bool |
|
350 | + */ |
|
351 | + public function copy($path1, $path2) { |
|
352 | + return $this->storage->copy($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * see http://php.net/manual/en/function.fopen.php |
|
357 | + * |
|
358 | + * @param string $path |
|
359 | + * @param string $mode |
|
360 | + * @return resource |
|
361 | + */ |
|
362 | + public function fopen($path, $mode) { |
|
363 | + $result = $this->storage->fopen($this->findPathToUse($path), $mode); |
|
364 | + if ($result && $mode !== 'r' && $mode !== 'rb') { |
|
365 | + unset($this->namesCache[$path]); |
|
366 | + } |
|
367 | + return $result; |
|
368 | + } |
|
369 | + |
|
370 | + /** |
|
371 | + * get the mimetype for a file or folder |
|
372 | + * The mimetype for a folder is required to be "httpd/unix-directory" |
|
373 | + * |
|
374 | + * @param string $path |
|
375 | + * @return string |
|
376 | + */ |
|
377 | + public function getMimeType($path) { |
|
378 | + return $this->storage->getMimeType($this->findPathToUse($path)); |
|
379 | + } |
|
380 | + |
|
381 | + /** |
|
382 | + * see http://php.net/manual/en/function.hash.php |
|
383 | + * |
|
384 | + * @param string $type |
|
385 | + * @param string $path |
|
386 | + * @param bool $raw |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function hash($type, $path, $raw = false) { |
|
390 | + return $this->storage->hash($type, $this->findPathToUse($path), $raw); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * see http://php.net/manual/en/function.free_space.php |
|
395 | + * |
|
396 | + * @param string $path |
|
397 | + * @return int |
|
398 | + */ |
|
399 | + public function free_space($path) { |
|
400 | + return $this->storage->free_space($this->findPathToUse($path)); |
|
401 | + } |
|
402 | + |
|
403 | + /** |
|
404 | + * search for occurrences of $query in file names |
|
405 | + * |
|
406 | + * @param string $query |
|
407 | + * @return array |
|
408 | + */ |
|
409 | + public function search($query) { |
|
410 | + return $this->storage->search($query); |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * see http://php.net/manual/en/function.touch.php |
|
415 | + * If the backend does not support the operation, false should be returned |
|
416 | + * |
|
417 | + * @param string $path |
|
418 | + * @param int $mtime |
|
419 | + * @return bool |
|
420 | + */ |
|
421 | + public function touch($path, $mtime = null) { |
|
422 | + return $this->storage->touch($this->findPathToUse($path), $mtime); |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * get the path to a local version of the file. |
|
427 | + * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
428 | + * |
|
429 | + * @param string $path |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + public function getLocalFile($path) { |
|
433 | + return $this->storage->getLocalFile($this->findPathToUse($path)); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * check if a file or folder has been updated since $time |
|
438 | + * |
|
439 | + * @param string $path |
|
440 | + * @param int $time |
|
441 | + * @return bool |
|
442 | + * |
|
443 | + * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
444 | + * returning true for other changes in the folder is optional |
|
445 | + */ |
|
446 | + public function hasUpdated($path, $time) { |
|
447 | + return $this->storage->hasUpdated($this->findPathToUse($path), $time); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * get a cache instance for the storage |
|
452 | + * |
|
453 | + * @param string $path |
|
454 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
455 | + * @return \OC\Files\Cache\Cache |
|
456 | + */ |
|
457 | + public function getCache($path = '', $storage = null) { |
|
458 | + if (!$storage) { |
|
459 | + $storage = $this; |
|
460 | + } |
|
461 | + return $this->storage->getCache($this->findPathToUse($path), $storage); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * get a scanner instance for the storage |
|
466 | + * |
|
467 | + * @param string $path |
|
468 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
469 | + * @return \OC\Files\Cache\Scanner |
|
470 | + */ |
|
471 | + public function getScanner($path = '', $storage = null) { |
|
472 | + if (!$storage) { |
|
473 | + $storage = $this; |
|
474 | + } |
|
475 | + return $this->storage->getScanner($this->findPathToUse($path), $storage); |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * get the ETag for a file or folder |
|
480 | + * |
|
481 | + * @param string $path |
|
482 | + * @return string |
|
483 | + */ |
|
484 | + public function getETag($path) { |
|
485 | + return $this->storage->getETag($this->findPathToUse($path)); |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * @param IStorage $sourceStorage |
|
490 | + * @param string $sourceInternalPath |
|
491 | + * @param string $targetInternalPath |
|
492 | + * @return bool |
|
493 | + */ |
|
494 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
495 | + if ($sourceStorage === $this) { |
|
496 | + return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
497 | + } |
|
498 | + |
|
499 | + $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
500 | + if ($result) { |
|
501 | + unset($this->namesCache[$targetInternalPath]); |
|
502 | + } |
|
503 | + return $result; |
|
504 | + } |
|
505 | + |
|
506 | + /** |
|
507 | + * @param IStorage $sourceStorage |
|
508 | + * @param string $sourceInternalPath |
|
509 | + * @param string $targetInternalPath |
|
510 | + * @return bool |
|
511 | + */ |
|
512 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
513 | + if ($sourceStorage === $this) { |
|
514 | + $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
515 | + if ($result) { |
|
516 | + unset($this->namesCache[$sourceInternalPath]); |
|
517 | + unset($this->namesCache[$targetInternalPath]); |
|
518 | + } |
|
519 | + return $result; |
|
520 | + } |
|
521 | + |
|
522 | + $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
523 | + if ($result) { |
|
524 | + unset($this->namesCache[$sourceInternalPath]); |
|
525 | + unset($this->namesCache[$targetInternalPath]); |
|
526 | + } |
|
527 | + return $result; |
|
528 | + } |
|
529 | + |
|
530 | + /** |
|
531 | + * @param string $path |
|
532 | + * @return array |
|
533 | + */ |
|
534 | + public function getMetaData($path) { |
|
535 | + return $this->storage->getMetaData($this->findPathToUse($path)); |
|
536 | + } |
|
537 | + |
|
538 | + public function getDirectoryContent($directory): \Traversable { |
|
539 | + return $this->storage->getDirectoryContent($this->findPathToUse($directory)); |
|
540 | + } |
|
541 | 541 | } |
@@ -37,45 +37,45 @@ |
||
37 | 37 | */ |
38 | 38 | trait LocalTempFileTrait { |
39 | 39 | |
40 | - /** @var string[] */ |
|
41 | - protected $cachedFiles = []; |
|
40 | + /** @var string[] */ |
|
41 | + protected $cachedFiles = []; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param string $path |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - protected function getCachedFile($path) { |
|
48 | - if (!isset($this->cachedFiles[$path])) { |
|
49 | - $this->cachedFiles[$path] = $this->toTmpFile($path); |
|
50 | - } |
|
51 | - return $this->cachedFiles[$path]; |
|
52 | - } |
|
43 | + /** |
|
44 | + * @param string $path |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + protected function getCachedFile($path) { |
|
48 | + if (!isset($this->cachedFiles[$path])) { |
|
49 | + $this->cachedFiles[$path] = $this->toTmpFile($path); |
|
50 | + } |
|
51 | + return $this->cachedFiles[$path]; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param string $path |
|
56 | - */ |
|
57 | - protected function removeCachedFile($path) { |
|
58 | - unset($this->cachedFiles[$path]); |
|
59 | - } |
|
54 | + /** |
|
55 | + * @param string $path |
|
56 | + */ |
|
57 | + protected function removeCachedFile($path) { |
|
58 | + unset($this->cachedFiles[$path]); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @param string $path |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - protected function toTmpFile($path) { //no longer in the storage api, still useful here |
|
66 | - $source = $this->fopen($path, 'r'); |
|
67 | - if (!$source) { |
|
68 | - return false; |
|
69 | - } |
|
70 | - if ($pos = strrpos($path, '.')) { |
|
71 | - $extension = substr($path, $pos); |
|
72 | - } else { |
|
73 | - $extension = ''; |
|
74 | - } |
|
75 | - $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); |
|
76 | - $target = fopen($tmpFile, 'w'); |
|
77 | - \OC_Helper::streamCopy($source, $target); |
|
78 | - fclose($target); |
|
79 | - return $tmpFile; |
|
80 | - } |
|
61 | + /** |
|
62 | + * @param string $path |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + protected function toTmpFile($path) { //no longer in the storage api, still useful here |
|
66 | + $source = $this->fopen($path, 'r'); |
|
67 | + if (!$source) { |
|
68 | + return false; |
|
69 | + } |
|
70 | + if ($pos = strrpos($path, '.')) { |
|
71 | + $extension = substr($path, $pos); |
|
72 | + } else { |
|
73 | + $extension = ''; |
|
74 | + } |
|
75 | + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); |
|
76 | + $target = fopen($tmpFile, 'w'); |
|
77 | + \OC_Helper::streamCopy($source, $target); |
|
78 | + fclose($target); |
|
79 | + return $tmpFile; |
|
80 | + } |
|
81 | 81 | } |
@@ -29,80 +29,80 @@ |
||
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 | } |
@@ -90,11 +90,11 @@ |
||
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) { |
@@ -25,81 +25,81 @@ |
||
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 | } |
@@ -89,11 +89,11 @@ |
||
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; |
@@ -26,27 +26,27 @@ |
||
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 | } |
@@ -26,40 +26,40 @@ |
||
26 | 26 | use OCP\Files\Notify\IChange; |
27 | 27 | |
28 | 28 | class Change implements IChange { |
29 | - /** @var int */ |
|
30 | - private $type; |
|
29 | + /** @var int */ |
|
30 | + private $type; |
|
31 | 31 | |
32 | - /** @var string */ |
|
33 | - private $path; |
|
32 | + /** @var string */ |
|
33 | + private $path; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Change constructor. |
|
37 | - * |
|
38 | - * @param int $type |
|
39 | - * @param string $path |
|
40 | - */ |
|
41 | - public function __construct($type, $path) { |
|
42 | - $this->type = $type; |
|
43 | - $this->path = $path; |
|
44 | - } |
|
35 | + /** |
|
36 | + * Change constructor. |
|
37 | + * |
|
38 | + * @param int $type |
|
39 | + * @param string $path |
|
40 | + */ |
|
41 | + public function __construct($type, $path) { |
|
42 | + $this->type = $type; |
|
43 | + $this->path = $path; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the type of the change |
|
48 | - * |
|
49 | - * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED |
|
50 | - */ |
|
51 | - public function getType() { |
|
52 | - return $this->type; |
|
53 | - } |
|
46 | + /** |
|
47 | + * Get the type of the change |
|
48 | + * |
|
49 | + * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED |
|
50 | + */ |
|
51 | + public function getType() { |
|
52 | + return $this->type; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the path of the file that was changed relative to the root of the storage |
|
57 | - * |
|
58 | - * Note, for rename changes this path is the old path for the file |
|
59 | - * |
|
60 | - * @return mixed |
|
61 | - */ |
|
62 | - public function getPath() { |
|
63 | - return $this->path; |
|
64 | - } |
|
55 | + /** |
|
56 | + * Get the path of the file that was changed relative to the root of the storage |
|
57 | + * |
|
58 | + * Note, for rename changes this path is the old path for the file |
|
59 | + * |
|
60 | + * @return mixed |
|
61 | + */ |
|
62 | + public function getPath() { |
|
63 | + return $this->path; |
|
64 | + } |
|
65 | 65 | } |
@@ -25,28 +25,28 @@ |
||
25 | 25 | use OCP\IDBConnection; |
26 | 26 | |
27 | 27 | class HomePropagator extends Propagator { |
28 | - private $ignoredBaseFolders; |
|
28 | + private $ignoredBaseFolders; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param \OC\Files\Storage\Storage $storage |
|
32 | - */ |
|
33 | - public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection) { |
|
34 | - parent::__construct($storage, $connection); |
|
35 | - $this->ignoredBaseFolders = ['files_encryption']; |
|
36 | - } |
|
30 | + /** |
|
31 | + * @param \OC\Files\Storage\Storage $storage |
|
32 | + */ |
|
33 | + public function __construct(\OC\Files\Storage\Storage $storage, IDBConnection $connection) { |
|
34 | + parent::__construct($storage, $connection); |
|
35 | + $this->ignoredBaseFolders = ['files_encryption']; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param string $internalPath |
|
41 | - * @param int $time |
|
42 | - * @param int $sizeDifference number of bytes the file has grown |
|
43 | - */ |
|
44 | - public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
45 | - list($baseFolder) = explode('/', $internalPath, 2); |
|
46 | - if (in_array($baseFolder, $this->ignoredBaseFolders)) { |
|
47 | - return []; |
|
48 | - } else { |
|
49 | - parent::propagateChange($internalPath, $time, $sizeDifference); |
|
50 | - } |
|
51 | - } |
|
39 | + /** |
|
40 | + * @param string $internalPath |
|
41 | + * @param int $time |
|
42 | + * @param int $sizeDifference number of bytes the file has grown |
|
43 | + */ |
|
44 | + public function propagateChange($internalPath, $time, $sizeDifference = 0) { |
|
45 | + list($baseFolder) = explode('/', $internalPath, 2); |
|
46 | + if (in_array($baseFolder, $this->ignoredBaseFolders)) { |
|
47 | + return []; |
|
48 | + } else { |
|
49 | + parent::propagateChange($internalPath, $time, $sizeDifference); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function getId() { |
61 | - return (int)$this->data['fileid']; |
|
61 | + return (int) $this->data['fileid']; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | public function getStorageId() { |
@@ -28,100 +28,100 @@ |
||
28 | 28 | * meta data for a file or folder |
29 | 29 | */ |
30 | 30 | class CacheEntry implements ICacheEntry, \ArrayAccess { |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - private $data; |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + private $data; |
|
35 | 35 | |
36 | - public function __construct(array $data) { |
|
37 | - $this->data = $data; |
|
38 | - } |
|
36 | + public function __construct(array $data) { |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - public function offsetSet($offset, $value) { |
|
41 | - $this->data[$offset] = $value; |
|
42 | - } |
|
40 | + public function offsetSet($offset, $value) { |
|
41 | + $this->data[$offset] = $value; |
|
42 | + } |
|
43 | 43 | |
44 | - public function offsetExists($offset) { |
|
45 | - return isset($this->data[$offset]); |
|
46 | - } |
|
44 | + public function offsetExists($offset) { |
|
45 | + return isset($this->data[$offset]); |
|
46 | + } |
|
47 | 47 | |
48 | - public function offsetUnset($offset) { |
|
49 | - unset($this->data[$offset]); |
|
50 | - } |
|
48 | + public function offsetUnset($offset) { |
|
49 | + unset($this->data[$offset]); |
|
50 | + } |
|
51 | 51 | |
52 | - public function offsetGet($offset) { |
|
53 | - if (isset($this->data[$offset])) { |
|
54 | - return $this->data[$offset]; |
|
55 | - } else { |
|
56 | - return null; |
|
57 | - } |
|
58 | - } |
|
52 | + public function offsetGet($offset) { |
|
53 | + if (isset($this->data[$offset])) { |
|
54 | + return $this->data[$offset]; |
|
55 | + } else { |
|
56 | + return null; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - public function getId() { |
|
61 | - return (int)$this->data['fileid']; |
|
62 | - } |
|
60 | + public function getId() { |
|
61 | + return (int)$this->data['fileid']; |
|
62 | + } |
|
63 | 63 | |
64 | - public function getStorageId() { |
|
65 | - return $this->data['storage']; |
|
66 | - } |
|
64 | + public function getStorageId() { |
|
65 | + return $this->data['storage']; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - public function getPath() { |
|
70 | - return $this->data['path']; |
|
71 | - } |
|
69 | + public function getPath() { |
|
70 | + return $this->data['path']; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - public function getName() { |
|
75 | - return $this->data['name']; |
|
76 | - } |
|
74 | + public function getName() { |
|
75 | + return $this->data['name']; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | - public function getMimeType() { |
|
80 | - return $this->data['mimetype']; |
|
81 | - } |
|
79 | + public function getMimeType() { |
|
80 | + return $this->data['mimetype']; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - public function getMimePart() { |
|
85 | - return $this->data['mimepart']; |
|
86 | - } |
|
84 | + public function getMimePart() { |
|
85 | + return $this->data['mimepart']; |
|
86 | + } |
|
87 | 87 | |
88 | - public function getSize() { |
|
89 | - return $this->data['size']; |
|
90 | - } |
|
88 | + public function getSize() { |
|
89 | + return $this->data['size']; |
|
90 | + } |
|
91 | 91 | |
92 | - public function getMTime() { |
|
93 | - return $this->data['mtime']; |
|
94 | - } |
|
92 | + public function getMTime() { |
|
93 | + return $this->data['mtime']; |
|
94 | + } |
|
95 | 95 | |
96 | - public function getStorageMTime() { |
|
97 | - return $this->data['storage_mtime']; |
|
98 | - } |
|
96 | + public function getStorageMTime() { |
|
97 | + return $this->data['storage_mtime']; |
|
98 | + } |
|
99 | 99 | |
100 | - public function getEtag() { |
|
101 | - return $this->data['etag']; |
|
102 | - } |
|
100 | + public function getEtag() { |
|
101 | + return $this->data['etag']; |
|
102 | + } |
|
103 | 103 | |
104 | - public function getPermissions() { |
|
105 | - return $this->data['permissions']; |
|
106 | - } |
|
104 | + public function getPermissions() { |
|
105 | + return $this->data['permissions']; |
|
106 | + } |
|
107 | 107 | |
108 | - public function isEncrypted() { |
|
109 | - return isset($this->data['encrypted']) && $this->data['encrypted']; |
|
110 | - } |
|
108 | + public function isEncrypted() { |
|
109 | + return isset($this->data['encrypted']) && $this->data['encrypted']; |
|
110 | + } |
|
111 | 111 | |
112 | - public function getMetadataEtag(): ?string { |
|
113 | - return $this->data['metadata_etag']; |
|
114 | - } |
|
112 | + public function getMetadataEtag(): ?string { |
|
113 | + return $this->data['metadata_etag']; |
|
114 | + } |
|
115 | 115 | |
116 | - public function getCreationTime(): ?int { |
|
117 | - return $this->data['creation_time']; |
|
118 | - } |
|
116 | + public function getCreationTime(): ?int { |
|
117 | + return $this->data['creation_time']; |
|
118 | + } |
|
119 | 119 | |
120 | - public function getUploadTime(): ?int { |
|
121 | - return $this->data['upload_time']; |
|
122 | - } |
|
120 | + public function getUploadTime(): ?int { |
|
121 | + return $this->data['upload_time']; |
|
122 | + } |
|
123 | 123 | |
124 | - public function getData() { |
|
125 | - return $this->data; |
|
126 | - } |
|
124 | + public function getData() { |
|
125 | + return $this->data; |
|
126 | + } |
|
127 | 127 | } |