@@ -66,10 +66,10 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | public function stream_seek($offset, $whence = SEEK_SET) { |
69 | - if ($whence === SEEK_END){ |
|
69 | + if ($whence === SEEK_END) { |
|
70 | 70 | // go to the end to find out last position's offset |
71 | 71 | $oldOffset = $this->stream_tell(); |
72 | - if (fseek($this->source, 0, $whence) !== 0){ |
|
72 | + if (fseek($this->source, 0, $whence) !== 0) { |
|
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | $whence = SEEK_SET; |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getMountsForUser(IUser $user) { |
75 | 75 | $loader = $this->loader; |
76 | - $mounts = array_map(function (IMountProvider $provider) use ($user, $loader) { |
|
76 | + $mounts = array_map(function(IMountProvider $provider) use ($user, $loader) { |
|
77 | 77 | return $provider->getMountsForUser($user, $loader); |
78 | 78 | }, $this->providers); |
79 | - $mounts = array_filter($mounts, function ($result) { |
|
79 | + $mounts = array_filter($mounts, function($result) { |
|
80 | 80 | return is_array($result); |
81 | 81 | }); |
82 | - return array_reduce($mounts, function (array $mounts, array $providerMounts) { |
|
82 | + return array_reduce($mounts, function(array $mounts, array $providerMounts) { |
|
83 | 83 | return array_merge($mounts, $providerMounts); |
84 | 84 | }, array()); |
85 | 85 | } |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | $providers = array_reverse($this->homeProviders); // call the latest registered provider first to give apps an opportunity to overwrite builtin |
97 | 97 | foreach ($providers as $homeProvider) { |
98 | 98 | if ($mount = $homeProvider->getHomeMountForUser($user, $this->loader)) { |
99 | - $mount->setMountPoint('/' . $user->getUID()); //make sure the mountpoint is what we expect |
|
99 | + $mount->setMountPoint('/'.$user->getUID()); //make sure the mountpoint is what we expect |
|
100 | 100 | return $mount; |
101 | 101 | } |
102 | 102 | } |
103 | - throw new \Exception('No home storage configured for user ' . $user); |
|
103 | + throw new \Exception('No home storage configured for user '.$user); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | public function registerMounts(IUser $user, array $mounts) { |
91 | 91 | // filter out non-proper storages coming from unit tests |
92 | - $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
92 | + $mounts = array_filter($mounts, function(IMountPoint $mount) { |
|
93 | 93 | return $mount instanceof SharedMount || $mount->getStorage() && $mount->getStorage()->getCache(); |
94 | 94 | }); |
95 | 95 | /** @var ICachedMountInfo[] $newMounts */ |
96 | - $newMounts = array_map(function (IMountPoint $mount) use ($user) { |
|
96 | + $newMounts = array_map(function(IMountPoint $mount) use ($user) { |
|
97 | 97 | // filter out any storages which aren't scanned yet since we aren't interested in files from those storages (yet) |
98 | 98 | if ($mount->getStorageRootId() === -1) { |
99 | 99 | return null; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $newMounts = array_values(array_filter($newMounts)); |
105 | 105 | |
106 | 106 | $cachedMounts = $this->getMountsForUser($user); |
107 | - $mountDiff = function (ICachedMountInfo $mount1, ICachedMountInfo $mount2) { |
|
107 | + $mountDiff = function(ICachedMountInfo $mount1, ICachedMountInfo $mount2) { |
|
108 | 108 | // since we are only looking for mounts for a specific user comparing on root id is enough |
109 | 109 | return $mount1->getRootId() - $mount2->getRootId(); |
110 | 110 | }; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | ], ['root_id', 'user_id']); |
166 | 166 | } else { |
167 | 167 | // in some cases this is legitimate, like orphaned shares |
168 | - $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); |
|
168 | + $this->logger->debug('Could not get storage info for mount at '.$mount->getMountPoint()); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | if (is_null($user)) { |
197 | 197 | return null; |
198 | 198 | } |
199 | - return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $row['mount_id'], isset($row['path'])? $row['path']:''); |
|
199 | + return new CachedMountInfo($user, (int) $row['storage_id'], (int) $row['root_id'], $row['mount_point'], $row['mount_id'], isset($row['path']) ? $row['path'] : ''); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $builder = $this->connection->getQueryBuilder(); |
227 | 227 | $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
228 | 228 | ->from('mounts', 'm') |
229 | - ->innerJoin('m', 'filecache', 'f' , $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
229 | + ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
230 | 230 | ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT))); |
231 | 231 | |
232 | 232 | $rows = $query->execute()->fetchAll(); |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | $row = $query->execute()->fetch(); |
266 | 266 | if (is_array($row)) { |
267 | 267 | $this->cacheInfoCache[$fileId] = [ |
268 | - (int)$row['storage'], |
|
268 | + (int) $row['storage'], |
|
269 | 269 | $row['path'], |
270 | - (int)$row['mimetype'] |
|
270 | + (int) $row['mimetype'] |
|
271 | 271 | ]; |
272 | 272 | } else { |
273 | - throw new NotFoundException('File with id "' . $fileId . '" not found'); |
|
273 | + throw new NotFoundException('File with id "'.$fileId.'" not found'); |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | return $this->cacheInfoCache[$fileId]; |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | $mountsForStorage = $this->getMountsForStorageId($storageId); |
291 | 291 | |
292 | 292 | // filter mounts that are from the same storage but a different directory |
293 | - return array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { |
|
293 | + return array_filter($mountsForStorage, function(ICachedMountInfo $mount) use ($internalPath, $fileId) { |
|
294 | 294 | if ($fileId === $mount->getRootId()) { |
295 | 295 | return true; |
296 | 296 | } |
297 | 297 | $internalMountPath = $mount->getRootInternalPath(); |
298 | 298 | |
299 | - return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; |
|
299 | + return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath.'/'; |
|
300 | 300 | }); |
301 | 301 | } |
302 | 302 |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | protected function attachListener($mount) { |
100 | 100 | $scanner = $mount->getStorage()->getScanner(); |
101 | 101 | $emitter = $this; |
102 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) { |
|
103 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); |
|
102 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function($path) use ($mount, $emitter) { |
|
103 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint().$path)); |
|
104 | 104 | }); |
105 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { |
|
106 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); |
|
105 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function($path) use ($mount, $emitter) { |
|
106 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint().$path)); |
|
107 | 107 | }); |
108 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { |
|
109 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); |
|
108 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function($path) use ($mount, $emitter) { |
|
109 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint().$path)); |
|
110 | 110 | }); |
111 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { |
|
112 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); |
|
111 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function($path) use ($mount, $emitter) { |
|
112 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint().$path)); |
|
113 | 113 | }); |
114 | 114 | } |
115 | 115 | |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $scanner = $storage->getScanner(); |
136 | 136 | $this->attachListener($mount); |
137 | 137 | |
138 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
138 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function($path) use ($storage) { |
|
139 | 139 | $this->triggerPropagator($storage, $path); |
140 | 140 | }); |
141 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
141 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function($path) use ($storage) { |
|
142 | 142 | $this->triggerPropagator($storage, $path); |
143 | 143 | }); |
144 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
144 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function($path) use ($storage) { |
|
145 | 145 | $this->triggerPropagator($storage, $path); |
146 | 146 | }); |
147 | 147 | |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | $this->attachListener($mount); |
189 | 189 | $isDbLocking = \OC::$server->getLockingProvider() instanceof DBLockingProvider; |
190 | 190 | |
191 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
191 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function($path) use ($storage) { |
|
192 | 192 | $this->triggerPropagator($storage, $path); |
193 | 193 | }); |
194 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
194 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function($path) use ($storage) { |
|
195 | 195 | $this->triggerPropagator($storage, $path); |
196 | 196 | }); |
197 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
197 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function($path) use ($storage) { |
|
198 | 198 | $this->triggerPropagator($storage, $path); |
199 | 199 | }); |
200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | } |
213 | 213 | $propagator->commitBatch(); |
214 | 214 | } catch (StorageNotAvailableException $e) { |
215 | - $this->logger->error('Storage ' . $storage->getId() . ' not available'); |
|
215 | + $this->logger->error('Storage '.$storage->getId().' not available'); |
|
216 | 216 | $this->logger->logException($e); |
217 | 217 | $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); |
218 | 218 | } |
@@ -24,8 +24,8 @@ |
||
24 | 24 | use OCP\Files\ObjectStore\IObjectStore; |
25 | 25 | |
26 | 26 | // TODO: proper composer |
27 | -set_include_path(get_include_path() . PATH_SEPARATOR . |
|
28 | - \OC_App::getAppPath('files_external') . '/3rdparty/aws-sdk-php'); |
|
27 | +set_include_path(get_include_path().PATH_SEPARATOR. |
|
28 | + \OC_App::getAppPath('files_external').'/3rdparty/aws-sdk-php'); |
|
29 | 29 | require_once 'aws-autoloader.php'; |
30 | 30 | |
31 | 31 | class S3 implements IObjectStore { |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | throw new \Exception('missing IObjectStore instance'); |
54 | 54 | } |
55 | 55 | if (isset($params['storageid'])) { |
56 | - $this->id = 'object::store:' . $params['storageid']; |
|
56 | + $this->id = 'object::store:'.$params['storageid']; |
|
57 | 57 | } else { |
58 | - $this->id = 'object::store:' . $this->objectStore->getStorageId(); |
|
58 | + $this->id = 'object::store:'.$this->objectStore->getStorageId(); |
|
59 | 59 | } |
60 | 60 | if (isset($params['objectPrefix'])) { |
61 | 61 | $this->objectPrefix = $params['objectPrefix']; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $this->objectStore->deleteObject($this->getURN($stat['fileid'])); |
186 | 186 | } catch (\Exception $ex) { |
187 | 187 | if ($ex->getCode() !== 404) { |
188 | - \OCP\Util::writeLog('objectstore', 'Could not delete object: ' . $ex->getMessage(), \OCP\Util::ERROR); |
|
188 | + \OCP\Util::writeLog('objectstore', 'Could not delete object: '.$ex->getMessage(), \OCP\Util::ERROR); |
|
189 | 189 | return false; |
190 | 190 | } else { |
191 | 191 | //removing from cache is ok as it does not exist in the objectstore anyway |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function getURN($fileId) { |
219 | 219 | if (is_numeric($fileId)) { |
220 | - return $this->objectPrefix . $fileId; |
|
220 | + return $this->objectPrefix.$fileId; |
|
221 | 221 | } |
222 | 222 | return null; |
223 | 223 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | try { |
264 | 264 | return $this->objectStore->readObject($this->getURN($stat['fileid'])); |
265 | 265 | } catch (\Exception $ex) { |
266 | - \OCP\Util::writeLog('objectstore', 'Could not get object: ' . $ex->getMessage(), \OCP\Util::ERROR); |
|
266 | + \OCP\Util::writeLog('objectstore', 'Could not get object: '.$ex->getMessage(), \OCP\Util::ERROR); |
|
267 | 267 | return false; |
268 | 268 | } |
269 | 269 | } else { |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | file_put_contents($tmpFile, $source); |
293 | 293 | } |
294 | 294 | $handle = fopen($tmpFile, $mode); |
295 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
295 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
296 | 296 | $this->writeBack($tmpFile, $path); |
297 | 297 | }); |
298 | 298 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | public function file_exists($path) { |
303 | 303 | $path = $this->normalizePath($path); |
304 | - return (bool)$this->stat($path); |
|
304 | + return (bool) $this->stat($path); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | public function rename($source, $target) { |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | $this->objectStore->writeObject($this->getURN($fileId), fopen('php://memory', 'r')); |
358 | 358 | } catch (\Exception $ex) { |
359 | 359 | $this->getCache()->remove($path); |
360 | - \OCP\Util::writeLog('objectstore', 'Could not create object: ' . $ex->getMessage(), \OCP\Util::ERROR); |
|
360 | + \OCP\Util::writeLog('objectstore', 'Could not create object: '.$ex->getMessage(), \OCP\Util::ERROR); |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | $this->objectStore->writeObject($this->getURN($fileId), fopen($tmpFile, 'r')); |
387 | 387 | } catch (\Exception $ex) { |
388 | 388 | $this->getCache()->remove($path); |
389 | - \OCP\Util::writeLog('objectstore', 'Could not create object: ' . $ex->getMessage(), \OCP\Util::ERROR); |
|
389 | + \OCP\Util::writeLog('objectstore', 'Could not create object: '.$ex->getMessage(), \OCP\Util::ERROR); |
|
390 | 390 | throw $ex; // make this bubble up |
391 | 391 | } |
392 | 392 | } |
@@ -33,15 +33,15 @@ |
||
33 | 33 | * @param array $params |
34 | 34 | */ |
35 | 35 | public function __construct($params) { |
36 | - if ( ! isset($params['user']) || ! $params['user'] instanceof User) { |
|
36 | + if (!isset($params['user']) || !$params['user'] instanceof User) { |
|
37 | 37 | throw new \Exception('missing user object in parameters'); |
38 | 38 | } |
39 | 39 | $this->user = $params['user']; |
40 | 40 | parent::__construct($params); |
41 | 41 | } |
42 | 42 | |
43 | - public function getId () { |
|
44 | - return 'object::user:' . $this->user->getUID(); |
|
43 | + public function getId() { |
|
44 | + return 'object::user:'.$this->user->getUID(); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -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 | } |
@@ -135,7 +135,7 @@ |
||
135 | 135 | |
136 | 136 | $stream = $objectContent->getStream(); |
137 | 137 | // save the object content in the context of the stream to prevent it being gc'd until the stream is closed |
138 | - stream_context_set_option($stream, 'swift','content', $objectContent); |
|
138 | + stream_context_set_option($stream, 'swift', 'content', $objectContent); |
|
139 | 139 | |
140 | 140 | return $stream; |
141 | 141 | } |