@@ -88,7 +88,7 @@ |
||
88 | 88 | if (strpos($path, '/webdav/') === 0) { |
89 | 89 | $path = substr($path, strlen('/webdav')); |
90 | 90 | } |
91 | - $path = $this->path . $path; |
|
91 | + $path = $this->path.$path; |
|
92 | 92 | $this->mimeType[$this->storage->getId()][$path] = $this->mimeTypeDetector->detectPath($path); |
93 | 93 | return $this->mimeType[$this->storage->getId()][$path]; |
94 | 94 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $authPlugin->addBackend($authBackend); |
100 | 100 | |
101 | 101 | // debugging |
102 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
102 | + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
103 | 103 | $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
104 | 104 | } else { |
105 | 105 | $this->server->addPlugin(new DummyGetResponsePlugin()); |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | |
153 | 153 | // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
154 | 154 | // we do not provide locking we emulate it using a fake locking plugin. |
155 | - if($request->isUserAgent([ |
|
155 | + if ($request->isUserAgent([ |
|
156 | 156 | '/WebDAVFS/', |
157 | 157 | '/Microsoft Office OneNote 2013/', |
158 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
158 | + '/^Microsoft-WebDAV/', // Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
159 | 159 | ])) { |
160 | 160 | $this->server->addPlugin(new FakeLockerPlugin()); |
161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | // wait with registering these until auth is handled and the filesystem is setup |
168 | - $this->server->on('beforeMethod', function () { |
|
168 | + $this->server->on('beforeMethod', function() { |
|
169 | 169 | // custom properties plugin must be the last one |
170 | 170 | $userSession = \OC::$server->getUserSession(); |
171 | 171 | $user = $userSession->getUser(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function shouldJoinTags(ISearchOperator $operator) { |
73 | 73 | if ($operator instanceof ISearchBinaryOperator) { |
74 | - return array_reduce($operator->getArguments(), function ($shouldJoin, ISearchOperator $operator) { |
|
74 | + return array_reduce($operator->getArguments(), function($shouldJoin, ISearchOperator $operator) { |
|
75 | 75 | return $shouldJoin || $this->shouldJoinTags($operator); |
76 | 76 | }, false); |
77 | 77 | } else if ($operator instanceof ISearchComparison) { |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | case ISearchBinaryOperator::OPERATOR_OR: |
97 | 97 | return $expr->orX($this->searchOperatorToDBExpr($builder, $operator->getArguments()[0]), $this->searchOperatorToDBExpr($builder, $operator->getArguments()[1])); |
98 | 98 | default: |
99 | - throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType()); |
|
99 | + throw new \InvalidArgumentException('Invalid operator type: '.$operator->getType()); |
|
100 | 100 | } |
101 | 101 | } else if ($operator instanceof ISearchComparison) { |
102 | 102 | return $this->searchComparisonToDBExpr($builder, $operator, self::$searchOperatorMap); |
103 | 103 | } else { |
104 | - throw new \InvalidArgumentException('Invalid operator type: ' . get_class($operator)); |
|
104 | + throw new \InvalidArgumentException('Invalid operator type: '.get_class($operator)); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $queryOperator = $operatorMap[$type]; |
114 | 114 | return $builder->expr()->$queryOperator($field, $this->getParameterForValue($builder, $value)); |
115 | 115 | } else { |
116 | - throw new \InvalidArgumentException('Invalid operator type: ' . $comparison->getType()); |
|
116 | + throw new \InvalidArgumentException('Invalid operator type: '.$comparison->getType()); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $type = ISearchComparison::COMPARE_EQUAL; |
133 | 133 | } |
134 | 134 | if (strpos($value, '%') !== false) { |
135 | - throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported'); |
|
135 | + throw new \InvalidArgumentException('Unsupported query value for mimetype: '.$value.', only values in the format "mime/type" or "mime/%" are supported'); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | } else if ($field === 'favorite') { |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | ]; |
164 | 164 | |
165 | 165 | if (!isset($types[$operator->getField()])) { |
166 | - throw new \InvalidArgumentException('Unsupported comparison field ' . $operator->getField()); |
|
166 | + throw new \InvalidArgumentException('Unsupported comparison field '.$operator->getField()); |
|
167 | 167 | } |
168 | 168 | $type = $types[$operator->getField()]; |
169 | 169 | if (gettype($operator->getValue()) !== $type) { |
170 | - throw new \InvalidArgumentException('Invalid type for field ' . $operator->getField()); |
|
170 | + throw new \InvalidArgumentException('Invalid type for field '.$operator->getField()); |
|
171 | 171 | } |
172 | 172 | if (!in_array($operator->getType(), $comparisons[$operator->getField()])) { |
173 | - throw new \InvalidArgumentException('Unsupported comparison for field ' . $operator->getField() . ': ' . $operator->getType()); |
|
173 | + throw new \InvalidArgumentException('Unsupported comparison for field '.$operator->getField().': '.$operator->getType()); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
@@ -46,11 +46,11 @@ |
||
46 | 46 | $tags = $getID3->analyze($tmpPath); |
47 | 47 | unlink($tmpPath); |
48 | 48 | $picture = isset($tags['id3v2']['APIC'][0]['data']) ? $tags['id3v2']['APIC'][0]['data'] : null; |
49 | - if(is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) { |
|
49 | + if (is_null($picture) && isset($tags['id3v2']['PIC'][0]['data'])) { |
|
50 | 50 | $picture = $tags['id3v2']['PIC'][0]['data']; |
51 | 51 | } |
52 | 52 | |
53 | - if(!is_null($picture)) { |
|
53 | + if (!is_null($picture)) { |
|
54 | 54 | $image = new \OC_Image(); |
55 | 55 | $image->loadFromData($picture); |
56 | 56 |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | 'remoteId' => $shareId |
135 | 135 | ); |
136 | 136 | |
137 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $id . '/reshare', $fields); |
|
137 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$id.'/reshare', $fields); |
|
138 | 138 | $status = json_decode($result['result'], true); |
139 | 139 | |
140 | 140 | $httpRequestSuccessful = $result['success']; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) { |
146 | 146 | return [ |
147 | 147 | $status['ocs']['data']['token'], |
148 | - (int)$status['ocs']['data']['remoteId'] |
|
148 | + (int) $status['ocs']['data']['remoteId'] |
|
149 | 149 | ]; |
150 | 150 | } |
151 | 151 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $fields[$key] = $value; |
230 | 230 | } |
231 | 231 | |
232 | - $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/' . $remoteId . '/' . $action, $fields); |
|
232 | + $result = $this->tryHttpPostToShareEndpoint(rtrim($remote, '/'), '/'.$remoteId.'/'.$action, $fields); |
|
233 | 233 | $status = json_decode($result['result'], true); |
234 | 234 | |
235 | 235 | if ($result['success'] && |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $client = $this->httpClientService->newClient(); |
281 | 281 | |
282 | 282 | if ($this->addressHandler->urlContainProtocol($remoteDomain) === false) { |
283 | - $remoteDomain = 'https://' . $remoteDomain; |
|
283 | + $remoteDomain = 'https://'.$remoteDomain; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | $result = [ |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | $federationEndpoints = $this->discoveryService->discover($remoteDomain, 'FEDERATED_SHARING'); |
292 | 292 | $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
293 | 293 | try { |
294 | - $response = $client->post($remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, [ |
|
294 | + $response = $client->post($remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, [ |
|
295 | 295 | 'body' => $fields, |
296 | 296 | 'timeout' => 10, |
297 | 297 | 'connect_timeout' => 10, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $secure = $protocol === 'https'; |
78 | 78 | $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING'); |
79 | 79 | $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav'; |
80 | - $root = rtrim($root, '/') . $webDavEndpoint; |
|
80 | + $root = rtrim($root, '/').$webDavEndpoint; |
|
81 | 81 | $this->mountPoint = $options['mountpoint']; |
82 | 82 | $this->token = $options['token']; |
83 | 83 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'host' => $host, |
87 | 87 | 'root' => $root, |
88 | 88 | 'user' => $options['token'], |
89 | - 'password' => (string)$options['password'] |
|
89 | + 'password' => (string) $options['password'] |
|
90 | 90 | )); |
91 | 91 | } |
92 | 92 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return string |
127 | 127 | */ |
128 | 128 | public function getId() { |
129 | - return 'shared::' . md5($this->token . '@' . $this->getRemote()); |
|
129 | + return 'shared::'.md5($this->token.'@'.$this->getRemote()); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function getCache($path = '', $storage = null) { |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | */ |
248 | 248 | protected function testRemote() { |
249 | 249 | try { |
250 | - return $this->testRemoteUrl($this->getRemote() . '/ocs-provider/index.php') |
|
251 | - || $this->testRemoteUrl($this->getRemote() . '/ocs-provider/') |
|
252 | - || $this->testRemoteUrl($this->getRemote() . '/status.php'); |
|
250 | + return $this->testRemoteUrl($this->getRemote().'/ocs-provider/index.php') |
|
251 | + || $this->testRemoteUrl($this->getRemote().'/ocs-provider/') |
|
252 | + || $this->testRemoteUrl($this->getRemote().'/status.php'); |
|
253 | 253 | } catch (\Exception $e) { |
254 | 254 | return false; |
255 | 255 | } |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | */ |
262 | 262 | private function testRemoteUrl($url) { |
263 | 263 | $cache = $this->memcacheFactory->create('files_sharing_remote_url'); |
264 | - if($cache->hasKey($url)) { |
|
265 | - return (bool)$cache->get($url); |
|
264 | + if ($cache->hasKey($url)) { |
|
265 | + return (bool) $cache->get($url); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | $client = $this->httpClient->newClient(); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return bool |
291 | 291 | */ |
292 | 292 | public function remoteIsOwnCloud() { |
293 | - if(defined('PHPUNIT_RUN') || !$this->testRemoteUrl($this->getRemote() . '/status.php')) { |
|
293 | + if (defined('PHPUNIT_RUN') || !$this->testRemoteUrl($this->getRemote().'/status.php')) { |
|
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | return true; |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | $password = $this->getPassword(); |
309 | 309 | |
310 | 310 | // If remote is not an ownCloud do not try to get any share info |
311 | - if(!$this->remoteIsOwnCloud()) { |
|
311 | + if (!$this->remoteIsOwnCloud()) { |
|
312 | 312 | return ['status' => 'unsupported']; |
313 | 313 | } |
314 | 314 | |
315 | - $url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token; |
|
315 | + $url = rtrim($remote, '/').'/index.php/apps/files_sharing/shareinfo?t='.$token; |
|
316 | 316 | |
317 | 317 | // TODO: DI |
318 | 318 | $client = \OC::$server->getHTTPClientService()->newClient(); |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | |
54 | 54 | class Storage { |
55 | 55 | |
56 | - const DEFAULTENABLED=true; |
|
57 | - const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota |
|
56 | + const DEFAULTENABLED = true; |
|
57 | + const DEFAULTMAXSIZE = 50; // unit: percentage; 50% of available disk space/quota |
|
58 | 58 | const VERSIONS_ROOT = 'files_versions/'; |
59 | 59 | |
60 | 60 | const DELETE_TRIGGER_MASTER_REMOVED = 0; |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | |
69 | 69 | private static $max_versions_per_interval = array( |
70 | 70 | //first 10sec, one version every 2sec |
71 | - 1 => array('intervalEndsAfter' => 10, 'step' => 2), |
|
71 | + 1 => array('intervalEndsAfter' => 10, 'step' => 2), |
|
72 | 72 | //next minute, one version every 10sec |
73 | - 2 => array('intervalEndsAfter' => 60, 'step' => 10), |
|
73 | + 2 => array('intervalEndsAfter' => 60, 'step' => 10), |
|
74 | 74 | //next hour, one version every minute |
75 | - 3 => array('intervalEndsAfter' => 3600, 'step' => 60), |
|
75 | + 3 => array('intervalEndsAfter' => 3600, 'step' => 60), |
|
76 | 76 | //next 24h, one version every hour |
77 | - 4 => array('intervalEndsAfter' => 86400, 'step' => 3600), |
|
77 | + 4 => array('intervalEndsAfter' => 86400, 'step' => 3600), |
|
78 | 78 | //next 30days, one version per day |
79 | 79 | 5 => array('intervalEndsAfter' => 2592000, 'step' => 86400), |
80 | 80 | //until the end one version per week |
81 | - 6 => array('intervalEndsAfter' => -1, 'step' => 604800), |
|
81 | + 6 => array('intervalEndsAfter' => -1, 'step' => 604800), |
|
82 | 82 | ); |
83 | 83 | |
84 | 84 | /** @var \OCA\Files_Versions\AppInfo\Application */ |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $uid = User::getUser(); |
103 | 103 | } |
104 | 104 | Filesystem::initMountPoints($uid); |
105 | - if ( $uid != User::getUser() ) { |
|
105 | + if ($uid != User::getUser()) { |
|
106 | 106 | $info = Filesystem::getFileInfo($filename); |
107 | 107 | $ownerView = new View('/'.$uid.'/files'); |
108 | 108 | try { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return int versions size |
153 | 153 | */ |
154 | 154 | private static function getVersionsSize($user) { |
155 | - $view = new View('/' . $user); |
|
155 | + $view = new View('/'.$user); |
|
156 | 156 | $fileInfo = $view->getFileInfo('/files_versions'); |
157 | 157 | return isset($fileInfo['size']) ? $fileInfo['size'] : 0; |
158 | 158 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * store a new version of a file. |
162 | 162 | */ |
163 | 163 | public static function store($filename) { |
164 | - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { |
|
164 | + if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') { |
|
165 | 165 | |
166 | 166 | // if the file gets streamed we need to remove the .part extension |
167 | 167 | // to get the right target |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | // we only handle existing files |
174 | - if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) { |
|
174 | + if (!Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
178 | 178 | list($uid, $filename) = self::getUidAndFilename($filename); |
179 | 179 | |
180 | - $files_view = new View('/'.$uid .'/files'); |
|
180 | + $files_view = new View('/'.$uid.'/files'); |
|
181 | 181 | $users_view = new View('/'.$uid); |
182 | 182 | |
183 | 183 | // no use making versions for empty files |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | self::scheduleExpire($uid, $filename); |
192 | 192 | |
193 | 193 | // store a new version of a file |
194 | - $mtime = $users_view->filemtime('files/' . $filename); |
|
195 | - $users_view->copy('files/' . $filename, 'files_versions/' . $filename . '.v' . $mtime); |
|
194 | + $mtime = $users_view->filemtime('files/'.$filename); |
|
195 | + $users_view->copy('files/'.$filename, 'files_versions/'.$filename.'.v'.$mtime); |
|
196 | 196 | // call getFileInfo to enforce a file cache entry for the new version |
197 | - $users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime); |
|
197 | + $users_view->getFileInfo('files_versions/'.$filename.'.v'.$mtime); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -238,14 +238,14 @@ discard block |
||
238 | 238 | |
239 | 239 | if (!Filesystem::file_exists($path)) { |
240 | 240 | |
241 | - $view = new View('/' . $uid . '/files_versions'); |
|
241 | + $view = new View('/'.$uid.'/files_versions'); |
|
242 | 242 | |
243 | 243 | $versions = self::getVersions($uid, $filename); |
244 | 244 | if (!empty($versions)) { |
245 | 245 | foreach ($versions as $v) { |
246 | - \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); |
|
247 | - self::deleteVersion($view, $filename . '.v' . $v['version']); |
|
248 | - \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path . $v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); |
|
246 | + \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path.$v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); |
|
247 | + self::deleteVersion($view, $filename.'.v'.$v['version']); |
|
248 | + \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path.$v['version'], 'trigger' => self::DELETE_TRIGGER_MASTER_REMOVED)); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
@@ -279,33 +279,33 @@ discard block |
||
279 | 279 | $rootView = new View(''); |
280 | 280 | |
281 | 281 | // did we move a directory ? |
282 | - if ($rootView->is_dir('/' . $targetOwner . '/files/' . $targetPath)) { |
|
282 | + if ($rootView->is_dir('/'.$targetOwner.'/files/'.$targetPath)) { |
|
283 | 283 | // does the directory exists for versions too ? |
284 | - if ($rootView->is_dir('/' . $sourceOwner . '/files_versions/' . $sourcePath)) { |
|
284 | + if ($rootView->is_dir('/'.$sourceOwner.'/files_versions/'.$sourcePath)) { |
|
285 | 285 | // create missing dirs if necessary |
286 | - self::createMissingDirectories($targetPath, new View('/'. $targetOwner)); |
|
286 | + self::createMissingDirectories($targetPath, new View('/'.$targetOwner)); |
|
287 | 287 | |
288 | 288 | // move the directory containing the versions |
289 | 289 | $rootView->$operation( |
290 | - '/' . $sourceOwner . '/files_versions/' . $sourcePath, |
|
291 | - '/' . $targetOwner . '/files_versions/' . $targetPath |
|
290 | + '/'.$sourceOwner.'/files_versions/'.$sourcePath, |
|
291 | + '/'.$targetOwner.'/files_versions/'.$targetPath |
|
292 | 292 | ); |
293 | 293 | } |
294 | - } else if ($versions = Storage::getVersions($sourceOwner, '/' . $sourcePath)) { |
|
294 | + } else if ($versions = Storage::getVersions($sourceOwner, '/'.$sourcePath)) { |
|
295 | 295 | // create missing dirs if necessary |
296 | - self::createMissingDirectories($targetPath, new View('/'. $targetOwner)); |
|
296 | + self::createMissingDirectories($targetPath, new View('/'.$targetOwner)); |
|
297 | 297 | |
298 | 298 | foreach ($versions as $v) { |
299 | 299 | // move each version one by one to the target directory |
300 | 300 | $rootView->$operation( |
301 | - '/' . $sourceOwner . '/files_versions/' . $sourcePath.'.v' . $v['version'], |
|
302 | - '/' . $targetOwner . '/files_versions/' . $targetPath.'.v'.$v['version'] |
|
301 | + '/'.$sourceOwner.'/files_versions/'.$sourcePath.'.v'.$v['version'], |
|
302 | + '/'.$targetOwner.'/files_versions/'.$targetPath.'.v'.$v['version'] |
|
303 | 303 | ); |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | 307 | // if we moved versions directly for a file, schedule expiration check for that file |
308 | - if (!$rootView->is_dir('/' . $targetOwner . '/files/' . $targetPath)) { |
|
308 | + if (!$rootView->is_dir('/'.$targetOwner.'/files/'.$targetPath)) { |
|
309 | 309 | self::scheduleExpire($targetOwner, $targetPath); |
310 | 310 | } |
311 | 311 | |
@@ -320,16 +320,16 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public static function rollback($file, $revision) { |
322 | 322 | |
323 | - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { |
|
323 | + if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') { |
|
324 | 324 | // add expected leading slash |
325 | - $file = '/' . ltrim($file, '/'); |
|
325 | + $file = '/'.ltrim($file, '/'); |
|
326 | 326 | list($uid, $filename) = self::getUidAndFilename($file); |
327 | 327 | if ($uid === null || trim($filename, '/') === '') { |
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | 331 | $users_view = new View('/'.$uid); |
332 | - $files_view = new View('/'. User::getUser().'/files'); |
|
332 | + $files_view = new View('/'.User::getUser().'/files'); |
|
333 | 333 | |
334 | 334 | $versionCreated = false; |
335 | 335 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $versionCreated = true; |
348 | 348 | } |
349 | 349 | |
350 | - $fileToRestore = 'files_versions' . $filename . '.v' . $revision; |
|
350 | + $fileToRestore = 'files_versions'.$filename.'.v'.$revision; |
|
351 | 351 | |
352 | 352 | // Restore encrypted version of the old file for the newly restored file |
353 | 353 | // This has to happen manually here since the file is manually copied below |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | ); |
364 | 364 | |
365 | 365 | // rollback |
366 | - if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) { |
|
366 | + if (self::copyFileContents($users_view, $fileToRestore, 'files'.$filename)) { |
|
367 | 367 | $files_view->touch($file, $revision); |
368 | 368 | Storage::scheduleExpire($uid, $file); |
369 | 369 | \OC_Hook::emit('\OCP\Versions', 'rollback', array( |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | return $versions; |
432 | 432 | } |
433 | 433 | // fetch for old versions |
434 | - $view = new View('/' . $uid . '/'); |
|
434 | + $view = new View('/'.$uid.'/'); |
|
435 | 435 | |
436 | 436 | $pathinfo = pathinfo($filename); |
437 | 437 | $versionedFile = $pathinfo['basename']; |
438 | 438 | |
439 | - $dir = Filesystem::normalizePath(self::VERSIONS_ROOT . '/' . $pathinfo['dirname']); |
|
439 | + $dir = Filesystem::normalizePath(self::VERSIONS_ROOT.'/'.$pathinfo['dirname']); |
|
440 | 440 | |
441 | 441 | $dirContent = false; |
442 | 442 | if ($view->is_dir($dir)) { |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $pathparts = pathinfo($entryName); |
457 | 457 | $timestamp = substr($pathparts['extension'], 1); |
458 | 458 | $filename = $pathparts['filename']; |
459 | - $key = $timestamp . '#' . $filename; |
|
459 | + $key = $timestamp.'#'.$filename; |
|
460 | 460 | $versions[$key]['version'] = $timestamp; |
461 | 461 | $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($timestamp); |
462 | 462 | if (empty($userFullPath)) { |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | } else { |
465 | 465 | $versions[$key]['preview'] = \OC::$server->getURLGenerator('files_version.Preview.getPreview', ['file' => $userFullPath, 'version' => $timestamp]); |
466 | 466 | } |
467 | - $versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename); |
|
467 | + $versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'].'/'.$filename); |
|
468 | 468 | $versions[$key]['name'] = $versionedFile; |
469 | - $versions[$key]['size'] = $view->filesize($dir . '/' . $entryName); |
|
469 | + $versions[$key]['size'] = $view->filesize($dir.'/'.$entryName); |
|
470 | 470 | $versions[$key]['mimetype'] = \OC::$server->getMimeTypeDetector()->detectPath($versionedFile); |
471 | 471 | } |
472 | 472 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | * Expire versions that older than max version retention time |
485 | 485 | * @param string $uid |
486 | 486 | */ |
487 | - public static function expireOlderThanMaxForUser($uid){ |
|
487 | + public static function expireOlderThanMaxForUser($uid) { |
|
488 | 488 | $expiration = self::getExpiration(); |
489 | 489 | $threshold = $expiration->getMaxAgeAsTimestamp(); |
490 | 490 | $versions = self::getAllVersions($uid); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | $toDelete = []; |
496 | 496 | foreach (array_reverse($versions['all']) as $key => $version) { |
497 | - if (intval($version['version'])<$threshold) { |
|
497 | + if (intval($version['version']) < $threshold) { |
|
498 | 498 | $toDelete[$key] = $version; |
499 | 499 | } else { |
500 | 500 | //Versions are sorted by time - nothing mo to iterate. |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | } |
503 | 503 | } |
504 | 504 | |
505 | - $view = new View('/' . $uid . '/files_versions'); |
|
505 | + $view = new View('/'.$uid.'/files_versions'); |
|
506 | 506 | if (!empty($toDelete)) { |
507 | 507 | foreach ($toDelete as $version) { |
508 | 508 | \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT)); |
509 | - self::deleteVersion($view, $version['path'] . '.v' . $version['version']); |
|
509 | + self::deleteVersion($view, $version['path'].'.v'.$version['version']); |
|
510 | 510 | \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_RETENTION_CONSTRAINT)); |
511 | 511 | } |
512 | 512 | } |
@@ -522,19 +522,19 @@ discard block |
||
522 | 522 | $diff = time() - $timestamp; |
523 | 523 | |
524 | 524 | if ($diff < 60) { // first minute |
525 | - return $diff . " seconds ago"; |
|
525 | + return $diff." seconds ago"; |
|
526 | 526 | } elseif ($diff < 3600) { //first hour |
527 | - return round($diff / 60) . " minutes ago"; |
|
527 | + return round($diff / 60)." minutes ago"; |
|
528 | 528 | } elseif ($diff < 86400) { // first day |
529 | - return round($diff / 3600) . " hours ago"; |
|
529 | + return round($diff / 3600)." hours ago"; |
|
530 | 530 | } elseif ($diff < 604800) { //first week |
531 | - return round($diff / 86400) . " days ago"; |
|
531 | + return round($diff / 86400)." days ago"; |
|
532 | 532 | } elseif ($diff < 2419200) { //first month |
533 | - return round($diff / 604800) . " weeks ago"; |
|
533 | + return round($diff / 604800)." weeks ago"; |
|
534 | 534 | } elseif ($diff < 29030400) { // first year |
535 | - return round($diff / 2419200) . " months ago"; |
|
535 | + return round($diff / 2419200)." months ago"; |
|
536 | 536 | } else { |
537 | - return round($diff / 29030400) . " years ago"; |
|
537 | + return round($diff / 29030400)." years ago"; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | } |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @return array with contains two arrays 'all' which contains all versions sorted by age and 'by_file' which contains all versions sorted by filename |
546 | 546 | */ |
547 | 547 | private static function getAllVersions($uid) { |
548 | - $view = new View('/' . $uid . '/'); |
|
548 | + $view = new View('/'.$uid.'/'); |
|
549 | 549 | $dirs = array(self::VERSIONS_ROOT); |
550 | 550 | $versions = array(); |
551 | 551 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | foreach ($files as $file) { |
557 | 557 | $fileData = $file->getData(); |
558 | - $filePath = $dir . '/' . $fileData['name']; |
|
558 | + $filePath = $dir.'/'.$fileData['name']; |
|
559 | 559 | if ($file['type'] === 'dir') { |
560 | 560 | array_push($dirs, $filePath); |
561 | 561 | } else { |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | $relPathStart = strlen(self::VERSIONS_ROOT); |
564 | 564 | $version = substr($filePath, $versionsBegin + 2); |
565 | 565 | $relpath = substr($filePath, $relPathStart, $versionsBegin - $relPathStart); |
566 | - $key = $version . '#' . $relpath; |
|
566 | + $key = $version.'#'.$relpath; |
|
567 | 567 | $versions[$key] = array('path' => $relpath, 'timestamp' => $version); |
568 | 568 | } |
569 | 569 | } |
@@ -604,13 +604,13 @@ discard block |
||
604 | 604 | list($toDelete, $size) = self::getAutoExpireList($time, $versions); |
605 | 605 | } else { |
606 | 606 | $size = 0; |
607 | - $toDelete = []; // versions we want to delete |
|
607 | + $toDelete = []; // versions we want to delete |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | foreach ($versions as $key => $version) { |
611 | 611 | if ($expiration->isExpired($version['version'], $quotaExceeded) && !isset($toDelete[$key])) { |
612 | 612 | $size += $version['size']; |
613 | - $toDelete[$key] = $version['path'] . '.v' . $version['version']; |
|
613 | + $toDelete[$key] = $version['path'].'.v'.$version['version']; |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | */ |
626 | 626 | protected static function getAutoExpireList($time, $versions) { |
627 | 627 | $size = 0; |
628 | - $toDelete = array(); // versions we want to delete |
|
628 | + $toDelete = array(); // versions we want to delete |
|
629 | 629 | |
630 | 630 | $interval = 1; |
631 | 631 | $step = Storage::$max_versions_per_interval[$interval]['step']; |
@@ -647,9 +647,9 @@ discard block |
||
647 | 647 | if ($nextInterval == -1 || $prevTimestamp > $nextInterval) { |
648 | 648 | if ($version['version'] > $nextVersion) { |
649 | 649 | //distance between two version too small, mark to delete |
650 | - $toDelete[$key] = $version['path'] . '.v' . $version['version']; |
|
650 | + $toDelete[$key] = $version['path'].'.v'.$version['version']; |
|
651 | 651 | $size += $version['size']; |
652 | - \OCP\Util::writeLog('files_versions', 'Mark to expire '. $version['path'] .' next version should be ' . $nextVersion . " or smaller. (prevTimestamp: " . $prevTimestamp . "; step: " . $step, \OCP\Util::INFO); |
|
652 | + \OCP\Util::writeLog('files_versions', 'Mark to expire '.$version['path'].' next version should be '.$nextVersion." or smaller. (prevTimestamp: ".$prevTimestamp."; step: ".$step, \OCP\Util::INFO); |
|
653 | 653 | } else { |
654 | 654 | $nextVersion = $version['version'] - $step; |
655 | 655 | $prevTimestamp = $version['version']; |
@@ -701,12 +701,12 @@ discard block |
||
701 | 701 | $config = \OC::$server->getConfig(); |
702 | 702 | $expiration = self::getExpiration(); |
703 | 703 | |
704 | - if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) { |
|
704 | + if ($config->getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true' && $expiration->isEnabled()) { |
|
705 | 705 | // get available disk space for user |
706 | 706 | $user = \OC::$server->getUserManager()->get($uid); |
707 | 707 | if (is_null($user)) { |
708 | - \OCP\Util::writeLog('files_versions', 'Backends provided no user object for ' . $uid, \OCP\Util::ERROR); |
|
709 | - throw new \OC\User\NoUserException('Backends provided no user object for ' . $uid); |
|
708 | + \OCP\Util::writeLog('files_versions', 'Backends provided no user object for '.$uid, \OCP\Util::ERROR); |
|
709 | + throw new \OC\User\NoUserException('Backends provided no user object for '.$uid); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | \OC_Util::setupFS($uid); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | |
724 | 724 | $softQuota = true; |
725 | 725 | $quota = $user->getQuota(); |
726 | - if ( $quota === null || $quota === 'none' ) { |
|
726 | + if ($quota === null || $quota === 'none') { |
|
727 | 727 | $quota = Filesystem::free_space('/'); |
728 | 728 | $softQuota = false; |
729 | 729 | } else { |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | // subtract size of files and current versions size from quota |
738 | 738 | if ($quota >= 0) { |
739 | 739 | if ($softQuota) { |
740 | - $files_view = new View('/' . $uid . '/files'); |
|
740 | + $files_view = new View('/'.$uid.'/files'); |
|
741 | 741 | $rootInfo = $files_view->getFileInfo('/', false); |
742 | 742 | $free = $quota - $rootInfo['size']; // remaining free space for user |
743 | 743 | if ($free > 0) { |
@@ -774,18 +774,18 @@ discard block |
||
774 | 774 | $versionsSize = $versionsSize - $sizeOfDeletedVersions; |
775 | 775 | } |
776 | 776 | |
777 | - foreach($toDelete as $key => $path) { |
|
777 | + foreach ($toDelete as $key => $path) { |
|
778 | 778 | \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); |
779 | 779 | self::deleteVersion($versionsFileview, $path); |
780 | 780 | \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $path, 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); |
781 | 781 | unset($allVersions[$key]); // update array with the versions we keep |
782 | - \OCP\Util::writeLog('files_versions', "Expire: " . $path, \OCP\Util::INFO); |
|
782 | + \OCP\Util::writeLog('files_versions', "Expire: ".$path, \OCP\Util::INFO); |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | // Check if enough space is available after versions are rearranged. |
786 | 786 | // If not we delete the oldest versions until we meet the size limit for versions, |
787 | 787 | // but always keep the two latest versions |
788 | - $numOfVersions = count($allVersions) -2 ; |
|
788 | + $numOfVersions = count($allVersions) - 2; |
|
789 | 789 | $i = 0; |
790 | 790 | // sort oldest first and make sure that we start at the first element |
791 | 791 | ksort($allVersions); |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | while ($availableSpace < 0 && $i < $numOfVersions) { |
794 | 794 | $version = current($allVersions); |
795 | 795 | \OC_Hook::emit('\OCP\Versions', 'preDelete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); |
796 | - self::deleteVersion($versionsFileview, $version['path'] . '.v' . $version['version']); |
|
796 | + self::deleteVersion($versionsFileview, $version['path'].'.v'.$version['version']); |
|
797 | 797 | \OC_Hook::emit('\OCP\Versions', 'delete', array('path' => $version['path'].'.v'.$version['version'], 'trigger' => self::DELETE_TRIGGER_QUOTA_EXCEEDED)); |
798 | - \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: ' . $version['path'].'.v'.$version['version'] , \OCP\Util::INFO); |
|
798 | + \OCP\Util::writeLog('files_versions', 'running out of space! Delete oldest version: '.$version['path'].'.v'.$version['version'], \OCP\Util::INFO); |
|
799 | 799 | $versionsSize -= $version['size']; |
800 | 800 | $availableSpace += $version['size']; |
801 | 801 | next($allVersions); |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | $dirParts = explode('/', $dirname); |
822 | 822 | $dir = "/files_versions"; |
823 | 823 | foreach ($dirParts as $part) { |
824 | - $dir = $dir . '/' . $part; |
|
824 | + $dir = $dir.'/'.$part; |
|
825 | 825 | if (!$view->file_exists($dir)) { |
826 | 826 | $view->mkdir($dir); |
827 | 827 | } |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * Static workaround |
833 | 833 | * @return Expiration |
834 | 834 | */ |
835 | - protected static function getExpiration(){ |
|
835 | + protected static function getExpiration() { |
|
836 | 836 | if (is_null(self::$application)) { |
837 | 837 | self::$application = new Application(); |
838 | 838 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($provider === null) { |
217 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
217 | + throw new ProviderException('No provider with id .'.$id.' found.'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $provider; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | |
243 | 243 | if ($provider === null) { |
244 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
244 | + throw new ProviderException('No share provider for share type '.$shareType); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $provider; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | OC::$CLASSPATH['OC_Mount_Config'] = 'files_external/lib/config.php'; |
31 | 31 | |
32 | -require_once __DIR__ . '/../3rdparty/autoload.php'; |
|
32 | +require_once __DIR__.'/../3rdparty/autoload.php'; |
|
33 | 33 | |
34 | 34 | // register Application object singleton |
35 | 35 | \OC_Mount_Config::$app = new \OCA\Files_External\AppInfo\Application(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | \OC_Mount_Config::$app->registerSettings(); |
39 | 39 | |
40 | -\OCA\Files\App::getNavigationManager()->add(function () { |
|
40 | +\OCA\Files\App::getNavigationManager()->add(function() { |
|
41 | 41 | $l = \OC::$server->getL10N('files_external'); |
42 | 42 | return [ |
43 | 43 | 'id' => 'extstoragemounts', |