@@ -30,38 +30,38 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IQuery { |
33 | - /** |
|
34 | - * @return string |
|
35 | - * @since 8.0.0 |
|
36 | - */ |
|
37 | - public function getSql(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + * @since 8.0.0 |
|
36 | + */ |
|
37 | + public function getSql(); |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return array |
|
41 | - * @since 8.0.0 |
|
42 | - */ |
|
43 | - public function getParams(); |
|
39 | + /** |
|
40 | + * @return array |
|
41 | + * @since 8.0.0 |
|
42 | + */ |
|
43 | + public function getParams(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return float |
|
47 | - * @since 8.0.0 |
|
48 | - */ |
|
49 | - public function getDuration(); |
|
45 | + /** |
|
46 | + * @return float |
|
47 | + * @since 8.0.0 |
|
48 | + */ |
|
49 | + public function getDuration(); |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return float |
|
53 | - * @since 11.0.0 |
|
54 | - */ |
|
55 | - public function getStartTime(); |
|
51 | + /** |
|
52 | + * @return float |
|
53 | + * @since 11.0.0 |
|
54 | + */ |
|
55 | + public function getStartTime(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return array |
|
59 | - * @since 11.0.0 |
|
60 | - */ |
|
61 | - public function getStacktrace(); |
|
62 | - /** |
|
63 | - * @return array |
|
64 | - * @since 12.0.0 |
|
65 | - */ |
|
66 | - public function getStart(); |
|
57 | + /** |
|
58 | + * @return array |
|
59 | + * @since 11.0.0 |
|
60 | + */ |
|
61 | + public function getStacktrace(); |
|
62 | + /** |
|
63 | + * @return array |
|
64 | + * @since 12.0.0 |
|
65 | + */ |
|
66 | + public function getStart(); |
|
67 | 67 | } |
@@ -28,56 +28,56 @@ |
||
28 | 28 | use OCP\Diagnostics\IEventLogger; |
29 | 29 | |
30 | 30 | class EventLogger implements IEventLogger { |
31 | - /** |
|
32 | - * @var \OC\Diagnostics\Event[] |
|
33 | - */ |
|
34 | - private $events = []; |
|
31 | + /** |
|
32 | + * @var \OC\Diagnostics\Event[] |
|
33 | + */ |
|
34 | + private $events = []; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var bool - Module needs to be activated by some app |
|
38 | - */ |
|
39 | - private $activated = false; |
|
36 | + /** |
|
37 | + * @var bool - Module needs to be activated by some app |
|
38 | + */ |
|
39 | + private $activated = false; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @inheritdoc |
|
43 | - */ |
|
44 | - public function start($id, $description) { |
|
45 | - if ($this->activated){ |
|
46 | - $this->events[$id] = new Event($id, $description, microtime(true)); |
|
47 | - } |
|
48 | - } |
|
41 | + /** |
|
42 | + * @inheritdoc |
|
43 | + */ |
|
44 | + public function start($id, $description) { |
|
45 | + if ($this->activated){ |
|
46 | + $this->events[$id] = new Event($id, $description, microtime(true)); |
|
47 | + } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @inheritdoc |
|
52 | - */ |
|
53 | - public function end($id) { |
|
54 | - if ($this->activated && isset($this->events[$id])) { |
|
55 | - $timing = $this->events[$id]; |
|
56 | - $timing->end(microtime(true)); |
|
57 | - } |
|
58 | - } |
|
50 | + /** |
|
51 | + * @inheritdoc |
|
52 | + */ |
|
53 | + public function end($id) { |
|
54 | + if ($this->activated && isset($this->events[$id])) { |
|
55 | + $timing = $this->events[$id]; |
|
56 | + $timing->end(microtime(true)); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @inheritdoc |
|
62 | - */ |
|
63 | - public function log($id, $description, $start, $end) { |
|
64 | - if ($this->activated) { |
|
65 | - $this->events[$id] = new Event($id, $description, $start); |
|
66 | - $this->events[$id]->end($end); |
|
67 | - } |
|
68 | - } |
|
60 | + /** |
|
61 | + * @inheritdoc |
|
62 | + */ |
|
63 | + public function log($id, $description, $start, $end) { |
|
64 | + if ($this->activated) { |
|
65 | + $this->events[$id] = new Event($id, $description, $start); |
|
66 | + $this->events[$id]->end($end); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @inheritdoc |
|
72 | - */ |
|
73 | - public function getEvents() { |
|
74 | - return $this->events; |
|
75 | - } |
|
70 | + /** |
|
71 | + * @inheritdoc |
|
72 | + */ |
|
73 | + public function getEvents() { |
|
74 | + return $this->events; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @inheritdoc |
|
79 | - */ |
|
80 | - public function activate() { |
|
81 | - $this->activated = true; |
|
82 | - } |
|
77 | + /** |
|
78 | + * @inheritdoc |
|
79 | + */ |
|
80 | + public function activate() { |
|
81 | + $this->activated = true; |
|
82 | + } |
|
83 | 83 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @inheritdoc |
43 | 43 | */ |
44 | 44 | public function start($id, $description) { |
45 | - if ($this->activated){ |
|
45 | + if ($this->activated) { |
|
46 | 46 | $this->events[$id] = new Event($id, $description, microtime(true)); |
47 | 47 | } |
48 | 48 | } |
@@ -118,17 +118,17 @@ discard block |
||
118 | 118 | protected function attachListener($mount) { |
119 | 119 | $scanner = $mount->getStorage()->getScanner(); |
120 | 120 | $emitter = $this; |
121 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) { |
|
122 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); |
|
121 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function($path) use ($mount, $emitter) { |
|
122 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint().$path)); |
|
123 | 123 | }); |
124 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { |
|
125 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); |
|
124 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function($path) use ($mount, $emitter) { |
|
125 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint().$path)); |
|
126 | 126 | }); |
127 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { |
|
128 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); |
|
127 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function($path) use ($mount, $emitter) { |
|
128 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint().$path)); |
|
129 | 129 | }); |
130 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { |
|
131 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); |
|
130 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function($path) use ($mount, $emitter) { |
|
131 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint().$path)); |
|
132 | 132 | }); |
133 | 133 | } |
134 | 134 | |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | $scanner = $storage->getScanner(); |
161 | 161 | $this->attachListener($mount); |
162 | 162 | |
163 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
163 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function($path) use ($storage) { |
|
164 | 164 | $this->triggerPropagator($storage, $path); |
165 | 165 | }); |
166 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
166 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function($path) use ($storage) { |
|
167 | 167 | $this->triggerPropagator($storage, $path); |
168 | 168 | }); |
169 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
169 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function($path) use ($storage) { |
|
170 | 170 | $this->triggerPropagator($storage, $path); |
171 | 171 | }); |
172 | 172 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | $scanner->setUseTransactions(false); |
220 | 220 | $this->attachListener($mount); |
221 | 221 | |
222 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
222 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function($path) use ($storage) { |
|
223 | 223 | $this->postProcessEntry($storage, $path); |
224 | 224 | }); |
225 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
225 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function($path) use ($storage) { |
|
226 | 226 | $this->postProcessEntry($storage, $path); |
227 | 227 | }); |
228 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
228 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function($path) use ($storage) { |
|
229 | 229 | $this->postProcessEntry($storage, $path); |
230 | 230 | }); |
231 | 231 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | $propagator->commitBatch(); |
249 | 249 | } catch (StorageNotAvailableException $e) { |
250 | - $this->logger->error('Storage ' . $storage->getId() . ' not available'); |
|
250 | + $this->logger->error('Storage '.$storage->getId().' not available'); |
|
251 | 251 | $this->logger->logException($e); |
252 | 252 | $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); |
253 | 253 | } |
@@ -182,7 +182,7 @@ |
||
182 | 182 | |
183 | 183 | /** |
184 | 184 | * @param string $dir |
185 | - * @param $recursive |
|
185 | + * @param boolean $recursive |
|
186 | 186 | * @param callable|null $mountFilter |
187 | 187 | * @throws ForbiddenException |
188 | 188 | * @throws NotFoundException |
@@ -50,238 +50,238 @@ |
||
50 | 50 | * @package OC\Files\Utils |
51 | 51 | */ |
52 | 52 | class Scanner extends PublicEmitter { |
53 | - const MAX_ENTRIES_TO_COMMIT = 10000; |
|
53 | + const MAX_ENTRIES_TO_COMMIT = 10000; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string $user |
|
57 | - */ |
|
58 | - private $user; |
|
55 | + /** |
|
56 | + * @var string $user |
|
57 | + */ |
|
58 | + private $user; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var \OCP\IDBConnection |
|
62 | - */ |
|
63 | - protected $db; |
|
60 | + /** |
|
61 | + * @var \OCP\IDBConnection |
|
62 | + */ |
|
63 | + protected $db; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var ILogger |
|
67 | - */ |
|
68 | - protected $logger; |
|
65 | + /** |
|
66 | + * @var ILogger |
|
67 | + */ |
|
68 | + protected $logger; |
|
69 | 69 | |
70 | - /** |
|
71 | - * Whether to use a DB transaction |
|
72 | - * |
|
73 | - * @var bool |
|
74 | - */ |
|
75 | - protected $useTransaction; |
|
70 | + /** |
|
71 | + * Whether to use a DB transaction |
|
72 | + * |
|
73 | + * @var bool |
|
74 | + */ |
|
75 | + protected $useTransaction; |
|
76 | 76 | |
77 | - /** |
|
78 | - * Number of entries scanned to commit |
|
79 | - * |
|
80 | - * @var int |
|
81 | - */ |
|
82 | - protected $entriesToCommit; |
|
77 | + /** |
|
78 | + * Number of entries scanned to commit |
|
79 | + * |
|
80 | + * @var int |
|
81 | + */ |
|
82 | + protected $entriesToCommit; |
|
83 | 83 | |
84 | - /** |
|
85 | - * @param string $user |
|
86 | - * @param \OCP\IDBConnection $db |
|
87 | - * @param ILogger $logger |
|
88 | - */ |
|
89 | - public function __construct($user, $db, ILogger $logger) { |
|
90 | - $this->logger = $logger; |
|
91 | - $this->user = $user; |
|
92 | - $this->db = $db; |
|
93 | - // when DB locking is used, no DB transactions will be used |
|
94 | - $this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider); |
|
95 | - } |
|
84 | + /** |
|
85 | + * @param string $user |
|
86 | + * @param \OCP\IDBConnection $db |
|
87 | + * @param ILogger $logger |
|
88 | + */ |
|
89 | + public function __construct($user, $db, ILogger $logger) { |
|
90 | + $this->logger = $logger; |
|
91 | + $this->user = $user; |
|
92 | + $this->db = $db; |
|
93 | + // when DB locking is used, no DB transactions will be used |
|
94 | + $this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * get all storages for $dir |
|
99 | - * |
|
100 | - * @param string $dir |
|
101 | - * @return \OC\Files\Mount\MountPoint[] |
|
102 | - */ |
|
103 | - protected function getMounts($dir) { |
|
104 | - //TODO: move to the node based fileapi once that's done |
|
105 | - \OC_Util::tearDownFS(); |
|
106 | - \OC_Util::setupFS($this->user); |
|
97 | + /** |
|
98 | + * get all storages for $dir |
|
99 | + * |
|
100 | + * @param string $dir |
|
101 | + * @return \OC\Files\Mount\MountPoint[] |
|
102 | + */ |
|
103 | + protected function getMounts($dir) { |
|
104 | + //TODO: move to the node based fileapi once that's done |
|
105 | + \OC_Util::tearDownFS(); |
|
106 | + \OC_Util::setupFS($this->user); |
|
107 | 107 | |
108 | - $mountManager = Filesystem::getMountManager(); |
|
109 | - $mounts = $mountManager->findIn($dir); |
|
110 | - $mounts[] = $mountManager->find($dir); |
|
111 | - $mounts = array_reverse($mounts); //start with the mount of $dir |
|
108 | + $mountManager = Filesystem::getMountManager(); |
|
109 | + $mounts = $mountManager->findIn($dir); |
|
110 | + $mounts[] = $mountManager->find($dir); |
|
111 | + $mounts = array_reverse($mounts); //start with the mount of $dir |
|
112 | 112 | |
113 | - return $mounts; |
|
114 | - } |
|
113 | + return $mounts; |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * attach listeners to the scanner |
|
118 | - * |
|
119 | - * @param \OC\Files\Mount\MountPoint $mount |
|
120 | - */ |
|
121 | - protected function attachListener($mount) { |
|
122 | - $scanner = $mount->getStorage()->getScanner(); |
|
123 | - $emitter = $this; |
|
124 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) { |
|
125 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); |
|
126 | - }); |
|
127 | - $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { |
|
128 | - $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); |
|
129 | - }); |
|
130 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { |
|
131 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); |
|
132 | - }); |
|
133 | - $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { |
|
134 | - $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); |
|
135 | - }); |
|
136 | - } |
|
116 | + /** |
|
117 | + * attach listeners to the scanner |
|
118 | + * |
|
119 | + * @param \OC\Files\Mount\MountPoint $mount |
|
120 | + */ |
|
121 | + protected function attachListener($mount) { |
|
122 | + $scanner = $mount->getStorage()->getScanner(); |
|
123 | + $emitter = $this; |
|
124 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFile', function ($path) use ($mount, $emitter) { |
|
125 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFile', array($mount->getMountPoint() . $path)); |
|
126 | + }); |
|
127 | + $scanner->listen('\OC\Files\Cache\Scanner', 'scanFolder', function ($path) use ($mount, $emitter) { |
|
128 | + $emitter->emit('\OC\Files\Utils\Scanner', 'scanFolder', array($mount->getMountPoint() . $path)); |
|
129 | + }); |
|
130 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFile', function ($path) use ($mount, $emitter) { |
|
131 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFile', array($mount->getMountPoint() . $path)); |
|
132 | + }); |
|
133 | + $scanner->listen('\OC\Files\Cache\Scanner', 'postScanFolder', function ($path) use ($mount, $emitter) { |
|
134 | + $emitter->emit('\OC\Files\Utils\Scanner', 'postScanFolder', array($mount->getMountPoint() . $path)); |
|
135 | + }); |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * @param string $dir |
|
140 | - */ |
|
141 | - public function backgroundScan($dir) { |
|
142 | - $mounts = $this->getMounts($dir); |
|
143 | - foreach ($mounts as $mount) { |
|
144 | - $storage = $mount->getStorage(); |
|
145 | - if (is_null($storage)) { |
|
146 | - continue; |
|
147 | - } |
|
138 | + /** |
|
139 | + * @param string $dir |
|
140 | + */ |
|
141 | + public function backgroundScan($dir) { |
|
142 | + $mounts = $this->getMounts($dir); |
|
143 | + foreach ($mounts as $mount) { |
|
144 | + $storage = $mount->getStorage(); |
|
145 | + if (is_null($storage)) { |
|
146 | + continue; |
|
147 | + } |
|
148 | 148 | |
149 | - // don't bother scanning failed storages (shortcut for same result) |
|
150 | - if ($storage->instanceOfStorage(FailedStorage::class)) { |
|
151 | - continue; |
|
152 | - } |
|
149 | + // don't bother scanning failed storages (shortcut for same result) |
|
150 | + if ($storage->instanceOfStorage(FailedStorage::class)) { |
|
151 | + continue; |
|
152 | + } |
|
153 | 153 | |
154 | - // don't scan the root storage |
|
155 | - if ($storage->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') { |
|
156 | - continue; |
|
157 | - } |
|
154 | + // don't scan the root storage |
|
155 | + if ($storage->instanceOfStorage('\OC\Files\Storage\Local') && $mount->getMountPoint() === '/') { |
|
156 | + continue; |
|
157 | + } |
|
158 | 158 | |
159 | - // don't scan received local shares, these can be scanned when scanning the owner's storage |
|
160 | - if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
161 | - continue; |
|
162 | - } |
|
163 | - $scanner = $storage->getScanner(); |
|
164 | - $this->attachListener($mount); |
|
159 | + // don't scan received local shares, these can be scanned when scanning the owner's storage |
|
160 | + if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
161 | + continue; |
|
162 | + } |
|
163 | + $scanner = $storage->getScanner(); |
|
164 | + $this->attachListener($mount); |
|
165 | 165 | |
166 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
167 | - $this->triggerPropagator($storage, $path); |
|
168 | - }); |
|
169 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
170 | - $this->triggerPropagator($storage, $path); |
|
171 | - }); |
|
172 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
173 | - $this->triggerPropagator($storage, $path); |
|
174 | - }); |
|
166 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
167 | + $this->triggerPropagator($storage, $path); |
|
168 | + }); |
|
169 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
170 | + $this->triggerPropagator($storage, $path); |
|
171 | + }); |
|
172 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
173 | + $this->triggerPropagator($storage, $path); |
|
174 | + }); |
|
175 | 175 | |
176 | - $propagator = $storage->getPropagator(); |
|
177 | - $propagator->beginBatch(); |
|
178 | - $scanner->backgroundScan(); |
|
179 | - $propagator->commitBatch(); |
|
180 | - } |
|
181 | - } |
|
176 | + $propagator = $storage->getPropagator(); |
|
177 | + $propagator->beginBatch(); |
|
178 | + $scanner->backgroundScan(); |
|
179 | + $propagator->commitBatch(); |
|
180 | + } |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * @param string $dir |
|
185 | - * @param $recursive |
|
186 | - * @param callable|null $mountFilter |
|
187 | - * @throws ForbiddenException |
|
188 | - * @throws NotFoundException |
|
189 | - */ |
|
190 | - public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, callable $mountFilter = null) { |
|
191 | - if (!Filesystem::isValidPath($dir)) { |
|
192 | - throw new \InvalidArgumentException('Invalid path to scan'); |
|
193 | - } |
|
194 | - $mounts = $this->getMounts($dir); |
|
195 | - foreach ($mounts as $mount) { |
|
196 | - if ($mountFilter && !$mountFilter($mount)) { |
|
197 | - continue; |
|
198 | - } |
|
199 | - $storage = $mount->getStorage(); |
|
200 | - if (is_null($storage)) { |
|
201 | - continue; |
|
202 | - } |
|
183 | + /** |
|
184 | + * @param string $dir |
|
185 | + * @param $recursive |
|
186 | + * @param callable|null $mountFilter |
|
187 | + * @throws ForbiddenException |
|
188 | + * @throws NotFoundException |
|
189 | + */ |
|
190 | + public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECURSIVE, callable $mountFilter = null) { |
|
191 | + if (!Filesystem::isValidPath($dir)) { |
|
192 | + throw new \InvalidArgumentException('Invalid path to scan'); |
|
193 | + } |
|
194 | + $mounts = $this->getMounts($dir); |
|
195 | + foreach ($mounts as $mount) { |
|
196 | + if ($mountFilter && !$mountFilter($mount)) { |
|
197 | + continue; |
|
198 | + } |
|
199 | + $storage = $mount->getStorage(); |
|
200 | + if (is_null($storage)) { |
|
201 | + continue; |
|
202 | + } |
|
203 | 203 | |
204 | - // don't bother scanning failed storages (shortcut for same result) |
|
205 | - if ($storage->instanceOfStorage(FailedStorage::class)) { |
|
206 | - continue; |
|
207 | - } |
|
204 | + // don't bother scanning failed storages (shortcut for same result) |
|
205 | + if ($storage->instanceOfStorage(FailedStorage::class)) { |
|
206 | + continue; |
|
207 | + } |
|
208 | 208 | |
209 | - // if the home storage isn't writable then the scanner is run as the wrong user |
|
210 | - if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and |
|
211 | - (!$storage->isCreatable('') or !$storage->isCreatable('files')) |
|
212 | - ) { |
|
213 | - if ($storage->file_exists('') or $storage->getCache()->inCache('')) { |
|
214 | - throw new ForbiddenException(); |
|
215 | - } else {// if the root exists in neither the cache nor the storage the user isn't setup yet |
|
216 | - break; |
|
217 | - } |
|
209 | + // if the home storage isn't writable then the scanner is run as the wrong user |
|
210 | + if ($storage->instanceOfStorage('\OC\Files\Storage\Home') and |
|
211 | + (!$storage->isCreatable('') or !$storage->isCreatable('files')) |
|
212 | + ) { |
|
213 | + if ($storage->file_exists('') or $storage->getCache()->inCache('')) { |
|
214 | + throw new ForbiddenException(); |
|
215 | + } else {// if the root exists in neither the cache nor the storage the user isn't setup yet |
|
216 | + break; |
|
217 | + } |
|
218 | 218 | |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - // don't scan received local shares, these can be scanned when scanning the owner's storage |
|
222 | - if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
223 | - continue; |
|
224 | - } |
|
225 | - $relativePath = $mount->getInternalPath($dir); |
|
226 | - $scanner = $storage->getScanner(); |
|
227 | - $scanner->setUseTransactions(false); |
|
228 | - $this->attachListener($mount); |
|
221 | + // don't scan received local shares, these can be scanned when scanning the owner's storage |
|
222 | + if ($storage->instanceOfStorage(SharedStorage::class)) { |
|
223 | + continue; |
|
224 | + } |
|
225 | + $relativePath = $mount->getInternalPath($dir); |
|
226 | + $scanner = $storage->getScanner(); |
|
227 | + $scanner->setUseTransactions(false); |
|
228 | + $this->attachListener($mount); |
|
229 | 229 | |
230 | - $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
231 | - $this->postProcessEntry($storage, $path); |
|
232 | - }); |
|
233 | - $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
234 | - $this->postProcessEntry($storage, $path); |
|
235 | - }); |
|
236 | - $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
237 | - $this->postProcessEntry($storage, $path); |
|
238 | - }); |
|
230 | + $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { |
|
231 | + $this->postProcessEntry($storage, $path); |
|
232 | + }); |
|
233 | + $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { |
|
234 | + $this->postProcessEntry($storage, $path); |
|
235 | + }); |
|
236 | + $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { |
|
237 | + $this->postProcessEntry($storage, $path); |
|
238 | + }); |
|
239 | 239 | |
240 | - if (!$storage->file_exists($relativePath)) { |
|
241 | - throw new NotFoundException($dir); |
|
242 | - } |
|
240 | + if (!$storage->file_exists($relativePath)) { |
|
241 | + throw new NotFoundException($dir); |
|
242 | + } |
|
243 | 243 | |
244 | - if ($this->useTransaction) { |
|
245 | - $this->db->beginTransaction(); |
|
246 | - } |
|
247 | - try { |
|
248 | - $propagator = $storage->getPropagator(); |
|
249 | - $propagator->beginBatch(); |
|
250 | - $scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); |
|
251 | - $cache = $storage->getCache(); |
|
252 | - if ($cache instanceof Cache) { |
|
253 | - // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner |
|
254 | - $cache->correctFolderSize($relativePath); |
|
255 | - } |
|
256 | - $propagator->commitBatch(); |
|
257 | - } catch (StorageNotAvailableException $e) { |
|
258 | - $this->logger->error('Storage ' . $storage->getId() . ' not available'); |
|
259 | - $this->logger->logException($e); |
|
260 | - $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); |
|
261 | - } |
|
262 | - if ($this->useTransaction) { |
|
263 | - $this->db->commit(); |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
244 | + if ($this->useTransaction) { |
|
245 | + $this->db->beginTransaction(); |
|
246 | + } |
|
247 | + try { |
|
248 | + $propagator = $storage->getPropagator(); |
|
249 | + $propagator->beginBatch(); |
|
250 | + $scanner->scan($relativePath, $recursive, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); |
|
251 | + $cache = $storage->getCache(); |
|
252 | + if ($cache instanceof Cache) { |
|
253 | + // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner |
|
254 | + $cache->correctFolderSize($relativePath); |
|
255 | + } |
|
256 | + $propagator->commitBatch(); |
|
257 | + } catch (StorageNotAvailableException $e) { |
|
258 | + $this->logger->error('Storage ' . $storage->getId() . ' not available'); |
|
259 | + $this->logger->logException($e); |
|
260 | + $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); |
|
261 | + } |
|
262 | + if ($this->useTransaction) { |
|
263 | + $this->db->commit(); |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | 267 | |
268 | - private function triggerPropagator(IStorage $storage, $internalPath) { |
|
269 | - $storage->getPropagator()->propagateChange($internalPath, time()); |
|
270 | - } |
|
268 | + private function triggerPropagator(IStorage $storage, $internalPath) { |
|
269 | + $storage->getPropagator()->propagateChange($internalPath, time()); |
|
270 | + } |
|
271 | 271 | |
272 | - private function postProcessEntry(IStorage $storage, $internalPath) { |
|
273 | - $this->triggerPropagator($storage, $internalPath); |
|
274 | - if ($this->useTransaction) { |
|
275 | - $this->entriesToCommit++; |
|
276 | - if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT) { |
|
277 | - $propagator = $storage->getPropagator(); |
|
278 | - $this->entriesToCommit = 0; |
|
279 | - $this->db->commit(); |
|
280 | - $propagator->commitBatch(); |
|
281 | - $this->db->beginTransaction(); |
|
282 | - $propagator->beginBatch(); |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
272 | + private function postProcessEntry(IStorage $storage, $internalPath) { |
|
273 | + $this->triggerPropagator($storage, $internalPath); |
|
274 | + if ($this->useTransaction) { |
|
275 | + $this->entriesToCommit++; |
|
276 | + if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT) { |
|
277 | + $propagator = $storage->getPropagator(); |
|
278 | + $this->entriesToCommit = 0; |
|
279 | + $this->db->commit(); |
|
280 | + $propagator->commitBatch(); |
|
281 | + $this->db->beginTransaction(); |
|
282 | + $propagator->beginBatch(); |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | 286 | } |
287 | 287 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | use OC\Files\Mount\MountPoint; |
25 | 25 | |
26 | 26 | class ExternalMountPoint extends MountPoint { |
27 | - public function getMountType() { |
|
28 | - return 'external'; |
|
29 | - } |
|
27 | + public function getMountType() { |
|
28 | + return 'external'; |
|
29 | + } |
|
30 | 30 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | if (isset($info['transferid'])) { |
91 | 91 | // getNodePath is called for multiple nodes within a chunk |
92 | 92 | // upload call |
93 | - $path = $dir . '/' . $info['name']; |
|
93 | + $path = $dir.'/'.$info['name']; |
|
94 | 94 | $path = ltrim($path, '/'); |
95 | 95 | } |
96 | 96 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } catch (StorageNotAvailableException $e) { |
162 | 162 | throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available'); |
163 | 163 | } catch (StorageInvalidException $e) { |
164 | - throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid'); |
|
164 | + throw new \Sabre\DAV\Exception\NotFound('Storage '.$path.' is invalid'); |
|
165 | 165 | } catch (LockedException $e) { |
166 | 166 | throw new \Sabre\DAV\Exception\Locked(); |
167 | 167 | } catch (ForbiddenException $e) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | if (!$info) { |
173 | - throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
173 | + throw new \Sabre\DAV\Exception\NotFound('File with name '.$path.' could not be located'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | if ($info->getType() === 'dir') { |
@@ -42,204 +42,204 @@ |
||
42 | 42 | |
43 | 43 | class ObjectTree extends CachingTree { |
44 | 44 | |
45 | - /** |
|
46 | - * @var \OC\Files\View |
|
47 | - */ |
|
48 | - protected $fileView; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var \OCP\Files\Mount\IMountManager |
|
52 | - */ |
|
53 | - protected $mountManager; |
|
54 | - |
|
55 | - /** |
|
56 | - * Creates the object |
|
57 | - */ |
|
58 | - public function __construct() { |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @param \Sabre\DAV\INode $rootNode |
|
63 | - * @param \OC\Files\View $view |
|
64 | - * @param \OCP\Files\Mount\IMountManager $mountManager |
|
65 | - */ |
|
66 | - public function init(\Sabre\DAV\INode $rootNode, \OC\Files\View $view, \OCP\Files\Mount\IMountManager $mountManager) { |
|
67 | - $this->rootNode = $rootNode; |
|
68 | - $this->fileView = $view; |
|
69 | - $this->mountManager = $mountManager; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * If the given path is a chunked file name, converts it |
|
74 | - * to the real file name. Only applies if the OC-CHUNKED header |
|
75 | - * is present. |
|
76 | - * |
|
77 | - * @param string $path chunk file path to convert |
|
78 | - * |
|
79 | - * @return string path to real file |
|
80 | - */ |
|
81 | - private function resolveChunkFile($path) { |
|
82 | - if (isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
83 | - // resolve to real file name to find the proper node |
|
84 | - list($dir, $name) = \Sabre\Uri\split($path); |
|
85 | - if ($dir === '/' || $dir === '.') { |
|
86 | - $dir = ''; |
|
87 | - } |
|
88 | - |
|
89 | - $info = \OC_FileChunking::decodeName($name); |
|
90 | - // only replace path if it was really the chunked file |
|
91 | - if (isset($info['transferid'])) { |
|
92 | - // getNodePath is called for multiple nodes within a chunk |
|
93 | - // upload call |
|
94 | - $path = $dir . '/' . $info['name']; |
|
95 | - $path = ltrim($path, '/'); |
|
96 | - } |
|
97 | - } |
|
98 | - return $path; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Returns the INode object for the requested path |
|
103 | - * |
|
104 | - * @param string $path |
|
105 | - * @return \Sabre\DAV\INode |
|
106 | - * @throws InvalidPath |
|
107 | - * @throws \Sabre\DAV\Exception\Locked |
|
108 | - * @throws \Sabre\DAV\Exception\NotFound |
|
109 | - * @throws \Sabre\DAV\Exception\ServiceUnavailable |
|
110 | - */ |
|
111 | - public function getNodeForPath($path) { |
|
112 | - if (!$this->fileView) { |
|
113 | - throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); |
|
114 | - } |
|
115 | - |
|
116 | - $path = trim($path, '/'); |
|
117 | - |
|
118 | - if (isset($this->cache[$path])) { |
|
119 | - return $this->cache[$path]; |
|
120 | - } |
|
121 | - |
|
122 | - if ($path) { |
|
123 | - try { |
|
124 | - $this->fileView->verifyPath($path, basename($path)); |
|
125 | - } catch (\OCP\Files\InvalidPathException $ex) { |
|
126 | - throw new InvalidPath($ex->getMessage()); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - // Is it the root node? |
|
131 | - if (!strlen($path)) { |
|
132 | - return $this->rootNode; |
|
133 | - } |
|
134 | - |
|
135 | - if (pathinfo($path, PATHINFO_EXTENSION) === 'part') { |
|
136 | - // read from storage |
|
137 | - $absPath = $this->fileView->getAbsolutePath($path); |
|
138 | - $mount = $this->fileView->getMount($path); |
|
139 | - $storage = $mount->getStorage(); |
|
140 | - $internalPath = $mount->getInternalPath($absPath); |
|
141 | - if ($storage && $storage->file_exists($internalPath)) { |
|
142 | - /** |
|
143 | - * @var \OC\Files\Storage\Storage $storage |
|
144 | - */ |
|
145 | - // get data directly |
|
146 | - $data = $storage->getMetaData($internalPath); |
|
147 | - $info = new FileInfo($absPath, $storage, $internalPath, $data, $mount); |
|
148 | - } else { |
|
149 | - $info = null; |
|
150 | - } |
|
151 | - } else { |
|
152 | - // resolve chunk file name to real name, if applicable |
|
153 | - $path = $this->resolveChunkFile($path); |
|
154 | - |
|
155 | - // read from cache |
|
156 | - try { |
|
157 | - $info = $this->fileView->getFileInfo($path); |
|
158 | - |
|
159 | - if ($info instanceof \OCP\Files\FileInfo && $info->getStorage()->instanceOfStorage(FailedStorage::class)) { |
|
160 | - throw new StorageNotAvailableException(); |
|
161 | - } |
|
162 | - } catch (StorageNotAvailableException $e) { |
|
163 | - throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available'); |
|
164 | - } catch (StorageInvalidException $e) { |
|
165 | - throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid'); |
|
166 | - } catch (LockedException $e) { |
|
167 | - throw new \Sabre\DAV\Exception\Locked(); |
|
168 | - } catch (ForbiddenException $e) { |
|
169 | - throw new \Sabre\DAV\Exception\Forbidden(); |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - if (!$info) { |
|
174 | - throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
175 | - } |
|
176 | - |
|
177 | - if ($info->getType() === 'dir') { |
|
178 | - $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this); |
|
179 | - } else { |
|
180 | - $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info); |
|
181 | - } |
|
182 | - |
|
183 | - $this->cache[$path] = $node; |
|
184 | - return $node; |
|
185 | - |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Copies a file or directory. |
|
190 | - * |
|
191 | - * This method must work recursively and delete the destination |
|
192 | - * if it exists |
|
193 | - * |
|
194 | - * @param string $source |
|
195 | - * @param string $destination |
|
196 | - * @throws FileLocked |
|
197 | - * @throws Forbidden |
|
198 | - * @throws InvalidPath |
|
199 | - * @throws \Exception |
|
200 | - * @throws \Sabre\DAV\Exception\Forbidden |
|
201 | - * @throws \Sabre\DAV\Exception\Locked |
|
202 | - * @throws \Sabre\DAV\Exception\NotFound |
|
203 | - * @throws \Sabre\DAV\Exception\ServiceUnavailable |
|
204 | - * @return void |
|
205 | - */ |
|
206 | - public function copy($source, $destination) { |
|
207 | - if (!$this->fileView) { |
|
208 | - throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - $info = $this->fileView->getFileInfo(dirname($destination)); |
|
213 | - if ($this->fileView->file_exists($destination)) { |
|
214 | - $destinationPermission = $info && $info->isUpdateable(); |
|
215 | - } else { |
|
216 | - $destinationPermission = $info && $info->isCreatable(); |
|
217 | - } |
|
218 | - if (!$destinationPermission) { |
|
219 | - throw new Forbidden('No permissions to copy object.'); |
|
220 | - } |
|
221 | - |
|
222 | - // this will trigger existence check |
|
223 | - $this->getNodeForPath($source); |
|
224 | - |
|
225 | - list($destinationDir, $destinationName) = \Sabre\Uri\split($destination); |
|
226 | - try { |
|
227 | - $this->fileView->verifyPath($destinationDir, $destinationName); |
|
228 | - } catch (\OCP\Files\InvalidPathException $ex) { |
|
229 | - throw new InvalidPath($ex->getMessage()); |
|
230 | - } |
|
231 | - |
|
232 | - try { |
|
233 | - $this->fileView->copy($source, $destination); |
|
234 | - } catch (StorageNotAvailableException $e) { |
|
235 | - throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage()); |
|
236 | - } catch (ForbiddenException $ex) { |
|
237 | - throw new Forbidden($ex->getMessage(), $ex->getRetry()); |
|
238 | - } catch (LockedException $e) { |
|
239 | - throw new FileLocked($e->getMessage(), $e->getCode(), $e); |
|
240 | - } |
|
241 | - |
|
242 | - list($destinationDir,) = \Sabre\Uri\split($destination); |
|
243 | - $this->markDirty($destinationDir); |
|
244 | - } |
|
45 | + /** |
|
46 | + * @var \OC\Files\View |
|
47 | + */ |
|
48 | + protected $fileView; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var \OCP\Files\Mount\IMountManager |
|
52 | + */ |
|
53 | + protected $mountManager; |
|
54 | + |
|
55 | + /** |
|
56 | + * Creates the object |
|
57 | + */ |
|
58 | + public function __construct() { |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @param \Sabre\DAV\INode $rootNode |
|
63 | + * @param \OC\Files\View $view |
|
64 | + * @param \OCP\Files\Mount\IMountManager $mountManager |
|
65 | + */ |
|
66 | + public function init(\Sabre\DAV\INode $rootNode, \OC\Files\View $view, \OCP\Files\Mount\IMountManager $mountManager) { |
|
67 | + $this->rootNode = $rootNode; |
|
68 | + $this->fileView = $view; |
|
69 | + $this->mountManager = $mountManager; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * If the given path is a chunked file name, converts it |
|
74 | + * to the real file name. Only applies if the OC-CHUNKED header |
|
75 | + * is present. |
|
76 | + * |
|
77 | + * @param string $path chunk file path to convert |
|
78 | + * |
|
79 | + * @return string path to real file |
|
80 | + */ |
|
81 | + private function resolveChunkFile($path) { |
|
82 | + if (isset($_SERVER['HTTP_OC_CHUNKED'])) { |
|
83 | + // resolve to real file name to find the proper node |
|
84 | + list($dir, $name) = \Sabre\Uri\split($path); |
|
85 | + if ($dir === '/' || $dir === '.') { |
|
86 | + $dir = ''; |
|
87 | + } |
|
88 | + |
|
89 | + $info = \OC_FileChunking::decodeName($name); |
|
90 | + // only replace path if it was really the chunked file |
|
91 | + if (isset($info['transferid'])) { |
|
92 | + // getNodePath is called for multiple nodes within a chunk |
|
93 | + // upload call |
|
94 | + $path = $dir . '/' . $info['name']; |
|
95 | + $path = ltrim($path, '/'); |
|
96 | + } |
|
97 | + } |
|
98 | + return $path; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Returns the INode object for the requested path |
|
103 | + * |
|
104 | + * @param string $path |
|
105 | + * @return \Sabre\DAV\INode |
|
106 | + * @throws InvalidPath |
|
107 | + * @throws \Sabre\DAV\Exception\Locked |
|
108 | + * @throws \Sabre\DAV\Exception\NotFound |
|
109 | + * @throws \Sabre\DAV\Exception\ServiceUnavailable |
|
110 | + */ |
|
111 | + public function getNodeForPath($path) { |
|
112 | + if (!$this->fileView) { |
|
113 | + throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); |
|
114 | + } |
|
115 | + |
|
116 | + $path = trim($path, '/'); |
|
117 | + |
|
118 | + if (isset($this->cache[$path])) { |
|
119 | + return $this->cache[$path]; |
|
120 | + } |
|
121 | + |
|
122 | + if ($path) { |
|
123 | + try { |
|
124 | + $this->fileView->verifyPath($path, basename($path)); |
|
125 | + } catch (\OCP\Files\InvalidPathException $ex) { |
|
126 | + throw new InvalidPath($ex->getMessage()); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + // Is it the root node? |
|
131 | + if (!strlen($path)) { |
|
132 | + return $this->rootNode; |
|
133 | + } |
|
134 | + |
|
135 | + if (pathinfo($path, PATHINFO_EXTENSION) === 'part') { |
|
136 | + // read from storage |
|
137 | + $absPath = $this->fileView->getAbsolutePath($path); |
|
138 | + $mount = $this->fileView->getMount($path); |
|
139 | + $storage = $mount->getStorage(); |
|
140 | + $internalPath = $mount->getInternalPath($absPath); |
|
141 | + if ($storage && $storage->file_exists($internalPath)) { |
|
142 | + /** |
|
143 | + * @var \OC\Files\Storage\Storage $storage |
|
144 | + */ |
|
145 | + // get data directly |
|
146 | + $data = $storage->getMetaData($internalPath); |
|
147 | + $info = new FileInfo($absPath, $storage, $internalPath, $data, $mount); |
|
148 | + } else { |
|
149 | + $info = null; |
|
150 | + } |
|
151 | + } else { |
|
152 | + // resolve chunk file name to real name, if applicable |
|
153 | + $path = $this->resolveChunkFile($path); |
|
154 | + |
|
155 | + // read from cache |
|
156 | + try { |
|
157 | + $info = $this->fileView->getFileInfo($path); |
|
158 | + |
|
159 | + if ($info instanceof \OCP\Files\FileInfo && $info->getStorage()->instanceOfStorage(FailedStorage::class)) { |
|
160 | + throw new StorageNotAvailableException(); |
|
161 | + } |
|
162 | + } catch (StorageNotAvailableException $e) { |
|
163 | + throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage is temporarily not available'); |
|
164 | + } catch (StorageInvalidException $e) { |
|
165 | + throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid'); |
|
166 | + } catch (LockedException $e) { |
|
167 | + throw new \Sabre\DAV\Exception\Locked(); |
|
168 | + } catch (ForbiddenException $e) { |
|
169 | + throw new \Sabre\DAV\Exception\Forbidden(); |
|
170 | + } |
|
171 | + } |
|
172 | + |
|
173 | + if (!$info) { |
|
174 | + throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located'); |
|
175 | + } |
|
176 | + |
|
177 | + if ($info->getType() === 'dir') { |
|
178 | + $node = new \OCA\DAV\Connector\Sabre\Directory($this->fileView, $info, $this); |
|
179 | + } else { |
|
180 | + $node = new \OCA\DAV\Connector\Sabre\File($this->fileView, $info); |
|
181 | + } |
|
182 | + |
|
183 | + $this->cache[$path] = $node; |
|
184 | + return $node; |
|
185 | + |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Copies a file or directory. |
|
190 | + * |
|
191 | + * This method must work recursively and delete the destination |
|
192 | + * if it exists |
|
193 | + * |
|
194 | + * @param string $source |
|
195 | + * @param string $destination |
|
196 | + * @throws FileLocked |
|
197 | + * @throws Forbidden |
|
198 | + * @throws InvalidPath |
|
199 | + * @throws \Exception |
|
200 | + * @throws \Sabre\DAV\Exception\Forbidden |
|
201 | + * @throws \Sabre\DAV\Exception\Locked |
|
202 | + * @throws \Sabre\DAV\Exception\NotFound |
|
203 | + * @throws \Sabre\DAV\Exception\ServiceUnavailable |
|
204 | + * @return void |
|
205 | + */ |
|
206 | + public function copy($source, $destination) { |
|
207 | + if (!$this->fileView) { |
|
208 | + throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup'); |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + $info = $this->fileView->getFileInfo(dirname($destination)); |
|
213 | + if ($this->fileView->file_exists($destination)) { |
|
214 | + $destinationPermission = $info && $info->isUpdateable(); |
|
215 | + } else { |
|
216 | + $destinationPermission = $info && $info->isCreatable(); |
|
217 | + } |
|
218 | + if (!$destinationPermission) { |
|
219 | + throw new Forbidden('No permissions to copy object.'); |
|
220 | + } |
|
221 | + |
|
222 | + // this will trigger existence check |
|
223 | + $this->getNodeForPath($source); |
|
224 | + |
|
225 | + list($destinationDir, $destinationName) = \Sabre\Uri\split($destination); |
|
226 | + try { |
|
227 | + $this->fileView->verifyPath($destinationDir, $destinationName); |
|
228 | + } catch (\OCP\Files\InvalidPathException $ex) { |
|
229 | + throw new InvalidPath($ex->getMessage()); |
|
230 | + } |
|
231 | + |
|
232 | + try { |
|
233 | + $this->fileView->copy($source, $destination); |
|
234 | + } catch (StorageNotAvailableException $e) { |
|
235 | + throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage()); |
|
236 | + } catch (ForbiddenException $ex) { |
|
237 | + throw new Forbidden($ex->getMessage(), $ex->getRetry()); |
|
238 | + } catch (LockedException $e) { |
|
239 | + throw new FileLocked($e->getMessage(), $e->getCode(), $e); |
|
240 | + } |
|
241 | + |
|
242 | + list($destinationDir,) = \Sabre\Uri\split($destination); |
|
243 | + $this->markDirty($destinationDir); |
|
244 | + } |
|
245 | 245 | } |
@@ -23,24 +23,24 @@ |
||
23 | 23 | |
24 | 24 | class SocialSharingBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return (string)$this->l10n->t('Social sharing bundle'); |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return (string)$this->l10n->t('Social sharing bundle'); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'socialsharing_twitter', |
|
39 | - 'socialsharing_googleplus', |
|
40 | - 'socialsharing_facebook', |
|
41 | - 'socialsharing_email', |
|
42 | - 'socialsharing_diaspora', |
|
43 | - ]; |
|
44 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'socialsharing_twitter', |
|
39 | + 'socialsharing_googleplus', |
|
40 | + 'socialsharing_facebook', |
|
41 | + 'socialsharing_email', |
|
42 | + 'socialsharing_diaspora', |
|
43 | + ]; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * {@inheritDoc} |
28 | 28 | */ |
29 | 29 | public function getName() { |
30 | - return (string)$this->l10n->t('Social sharing bundle'); |
|
30 | + return (string) $this->l10n->t('Social sharing bundle'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -29,103 +29,103 @@ |
||
29 | 29 | */ |
30 | 30 | interface IMountPoint { |
31 | 31 | |
32 | - /** |
|
33 | - * get complete path to the mount point |
|
34 | - * |
|
35 | - * @return string |
|
36 | - * @since 8.0.0 |
|
37 | - */ |
|
38 | - public function getMountPoint(); |
|
32 | + /** |
|
33 | + * get complete path to the mount point |
|
34 | + * |
|
35 | + * @return string |
|
36 | + * @since 8.0.0 |
|
37 | + */ |
|
38 | + public function getMountPoint(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * Set the mountpoint |
|
42 | - * |
|
43 | - * @param string $mountPoint new mount point |
|
44 | - * @since 8.0.0 |
|
45 | - */ |
|
46 | - public function setMountPoint($mountPoint); |
|
40 | + /** |
|
41 | + * Set the mountpoint |
|
42 | + * |
|
43 | + * @param string $mountPoint new mount point |
|
44 | + * @since 8.0.0 |
|
45 | + */ |
|
46 | + public function setMountPoint($mountPoint); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Get the storage that is mounted |
|
50 | - * |
|
51 | - * @return \OC\Files\Storage\Storage |
|
52 | - * @since 8.0.0 |
|
53 | - */ |
|
54 | - public function getStorage(); |
|
48 | + /** |
|
49 | + * Get the storage that is mounted |
|
50 | + * |
|
51 | + * @return \OC\Files\Storage\Storage |
|
52 | + * @since 8.0.0 |
|
53 | + */ |
|
54 | + public function getStorage(); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get the id of the storages |
|
58 | - * |
|
59 | - * @return string |
|
60 | - * @since 8.0.0 |
|
61 | - */ |
|
62 | - public function getStorageId(); |
|
56 | + /** |
|
57 | + * Get the id of the storages |
|
58 | + * |
|
59 | + * @return string |
|
60 | + * @since 8.0.0 |
|
61 | + */ |
|
62 | + public function getStorageId(); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Get the id of the storages |
|
66 | - * |
|
67 | - * @return int |
|
68 | - * @since 9.1.0 |
|
69 | - */ |
|
70 | - public function getNumericStorageId(); |
|
64 | + /** |
|
65 | + * Get the id of the storages |
|
66 | + * |
|
67 | + * @return int |
|
68 | + * @since 9.1.0 |
|
69 | + */ |
|
70 | + public function getNumericStorageId(); |
|
71 | 71 | |
72 | - /** |
|
73 | - * Get the path relative to the mountpoint |
|
74 | - * |
|
75 | - * @param string $path absolute path to a file or folder |
|
76 | - * @return string |
|
77 | - * @since 8.0.0 |
|
78 | - */ |
|
79 | - public function getInternalPath($path); |
|
72 | + /** |
|
73 | + * Get the path relative to the mountpoint |
|
74 | + * |
|
75 | + * @param string $path absolute path to a file or folder |
|
76 | + * @return string |
|
77 | + * @since 8.0.0 |
|
78 | + */ |
|
79 | + public function getInternalPath($path); |
|
80 | 80 | |
81 | - /** |
|
82 | - * Apply a storage wrapper to the mounted storage |
|
83 | - * |
|
84 | - * @param callable $wrapper |
|
85 | - * @since 8.0.0 |
|
86 | - */ |
|
87 | - public function wrapStorage($wrapper); |
|
81 | + /** |
|
82 | + * Apply a storage wrapper to the mounted storage |
|
83 | + * |
|
84 | + * @param callable $wrapper |
|
85 | + * @since 8.0.0 |
|
86 | + */ |
|
87 | + public function wrapStorage($wrapper); |
|
88 | 88 | |
89 | - /** |
|
90 | - * Get a mount option |
|
91 | - * |
|
92 | - * @param string $name Name of the mount option to get |
|
93 | - * @param mixed $default Default value for the mount option |
|
94 | - * @return mixed |
|
95 | - * @since 8.0.0 |
|
96 | - */ |
|
97 | - public function getOption($name, $default); |
|
89 | + /** |
|
90 | + * Get a mount option |
|
91 | + * |
|
92 | + * @param string $name Name of the mount option to get |
|
93 | + * @param mixed $default Default value for the mount option |
|
94 | + * @return mixed |
|
95 | + * @since 8.0.0 |
|
96 | + */ |
|
97 | + public function getOption($name, $default); |
|
98 | 98 | |
99 | - /** |
|
100 | - * Get all options for the mount |
|
101 | - * |
|
102 | - * @return array |
|
103 | - * @since 8.1.0 |
|
104 | - */ |
|
105 | - public function getOptions(); |
|
99 | + /** |
|
100 | + * Get all options for the mount |
|
101 | + * |
|
102 | + * @return array |
|
103 | + * @since 8.1.0 |
|
104 | + */ |
|
105 | + public function getOptions(); |
|
106 | 106 | |
107 | - /** |
|
108 | - * Get the file id of the root of the storage |
|
109 | - * |
|
110 | - * @return int |
|
111 | - * @since 9.1.0 |
|
112 | - */ |
|
113 | - public function getStorageRootId(); |
|
107 | + /** |
|
108 | + * Get the file id of the root of the storage |
|
109 | + * |
|
110 | + * @return int |
|
111 | + * @since 9.1.0 |
|
112 | + */ |
|
113 | + public function getStorageRootId(); |
|
114 | 114 | |
115 | - /** |
|
116 | - * Get the id of the configured mount |
|
117 | - * |
|
118 | - * @return int|null mount id or null if not applicable |
|
119 | - * @since 9.1.0 |
|
120 | - */ |
|
121 | - public function getMountId(); |
|
115 | + /** |
|
116 | + * Get the id of the configured mount |
|
117 | + * |
|
118 | + * @return int|null mount id or null if not applicable |
|
119 | + * @since 9.1.0 |
|
120 | + */ |
|
121 | + public function getMountId(); |
|
122 | 122 | |
123 | - /** |
|
124 | - * Get the type of mount point, used to distinguish things like shares and external storages |
|
125 | - * in the web interface |
|
126 | - * |
|
127 | - * @return string |
|
128 | - * @since 12.0.0 |
|
129 | - */ |
|
130 | - public function getMountType(); |
|
123 | + /** |
|
124 | + * Get the type of mount point, used to distinguish things like shares and external storages |
|
125 | + * in the web interface |
|
126 | + * |
|
127 | + * @return string |
|
128 | + * @since 12.0.0 |
|
129 | + */ |
|
130 | + public function getMountType(); |
|
131 | 131 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | protected function run($argument) { |
65 | - if($argument['retryNo'] === 5) { |
|
65 | + if ($argument['retryNo'] === 5) { |
|
66 | 66 | return; |
67 | 67 | } |
68 | 68 |
@@ -30,78 +30,78 @@ |
||
30 | 30 | use OCP\ILogger; |
31 | 31 | |
32 | 32 | class RetryJob extends Job { |
33 | - /** @var IClientService */ |
|
34 | - private $clientService; |
|
35 | - /** @var IJobList */ |
|
36 | - private $jobList; |
|
37 | - /** @var string */ |
|
38 | - private $lookupServer; |
|
39 | - /** @var int how much time should be between two tries (10 minutes) */ |
|
40 | - private $interval = 600; |
|
33 | + /** @var IClientService */ |
|
34 | + private $clientService; |
|
35 | + /** @var IJobList */ |
|
36 | + private $jobList; |
|
37 | + /** @var string */ |
|
38 | + private $lookupServer; |
|
39 | + /** @var int how much time should be between two tries (10 minutes) */ |
|
40 | + private $interval = 600; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IClientService $clientService |
|
44 | - * @param IJobList $jobList |
|
45 | - * @param IConfig $config |
|
46 | - */ |
|
47 | - public function __construct(IClientService $clientService, |
|
48 | - IJobList $jobList, |
|
49 | - IConfig $config) { |
|
50 | - $this->clientService = $clientService; |
|
51 | - $this->jobList = $jobList; |
|
42 | + /** |
|
43 | + * @param IClientService $clientService |
|
44 | + * @param IJobList $jobList |
|
45 | + * @param IConfig $config |
|
46 | + */ |
|
47 | + public function __construct(IClientService $clientService, |
|
48 | + IJobList $jobList, |
|
49 | + IConfig $config) { |
|
50 | + $this->clientService = $clientService; |
|
51 | + $this->jobList = $jobList; |
|
52 | 52 | |
53 | - $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); |
|
54 | - $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
55 | - $this->lookupServer .= '/users'; |
|
56 | - } |
|
53 | + $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); |
|
54 | + $this->lookupServer = rtrim($this->lookupServer, '/'); |
|
55 | + $this->lookupServer .= '/users'; |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * run the job, then remove it from the jobList |
|
60 | - * |
|
61 | - * @param JobList $jobList |
|
62 | - * @param ILogger|null $logger |
|
63 | - */ |
|
64 | - public function execute($jobList, ILogger $logger = null) { |
|
65 | - if ($this->shouldRun($this->argument)) { |
|
66 | - parent::execute($jobList, $logger); |
|
67 | - $jobList->remove($this, $this->argument); |
|
68 | - } |
|
69 | - } |
|
58 | + /** |
|
59 | + * run the job, then remove it from the jobList |
|
60 | + * |
|
61 | + * @param JobList $jobList |
|
62 | + * @param ILogger|null $logger |
|
63 | + */ |
|
64 | + public function execute($jobList, ILogger $logger = null) { |
|
65 | + if ($this->shouldRun($this->argument)) { |
|
66 | + parent::execute($jobList, $logger); |
|
67 | + $jobList->remove($this, $this->argument); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - protected function run($argument) { |
|
72 | - if($argument['retryNo'] === 5) { |
|
73 | - return; |
|
74 | - } |
|
71 | + protected function run($argument) { |
|
72 | + if($argument['retryNo'] === 5) { |
|
73 | + return; |
|
74 | + } |
|
75 | 75 | |
76 | - $client = $this->clientService->newClient(); |
|
76 | + $client = $this->clientService->newClient(); |
|
77 | 77 | |
78 | - try { |
|
79 | - $client->post($this->lookupServer, |
|
80 | - [ |
|
81 | - 'body' => json_encode($argument['dataArray']), |
|
82 | - 'timeout' => 10, |
|
83 | - 'connect_timeout' => 3, |
|
84 | - ] |
|
85 | - ); |
|
86 | - } catch (\Exception $e) { |
|
87 | - $this->jobList->add(RetryJob::class, |
|
88 | - [ |
|
89 | - 'dataArray' => $argument['dataArray'], |
|
90 | - 'retryNo' => $argument['retryNo'] + 1, |
|
91 | - 'lastRun' => time(), |
|
92 | - ] |
|
93 | - ); |
|
78 | + try { |
|
79 | + $client->post($this->lookupServer, |
|
80 | + [ |
|
81 | + 'body' => json_encode($argument['dataArray']), |
|
82 | + 'timeout' => 10, |
|
83 | + 'connect_timeout' => 3, |
|
84 | + ] |
|
85 | + ); |
|
86 | + } catch (\Exception $e) { |
|
87 | + $this->jobList->add(RetryJob::class, |
|
88 | + [ |
|
89 | + 'dataArray' => $argument['dataArray'], |
|
90 | + 'retryNo' => $argument['retryNo'] + 1, |
|
91 | + 'lastRun' => time(), |
|
92 | + ] |
|
93 | + ); |
|
94 | 94 | |
95 | - } |
|
96 | - } |
|
95 | + } |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * test if it is time for the next run |
|
100 | - * |
|
101 | - * @param array $argument |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - protected function shouldRun($argument) { |
|
105 | - return !isset($argument['lastRun']) || ((time() - $argument['lastRun']) > $this->interval); |
|
106 | - } |
|
98 | + /** |
|
99 | + * test if it is time for the next run |
|
100 | + * |
|
101 | + * @param array $argument |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + protected function shouldRun($argument) { |
|
105 | + return !isset($argument['lastRun']) || ((time() - $argument['lastRun']) > $this->interval); |
|
106 | + } |
|
107 | 107 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getShortFooter() { |
124 | 124 | $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
125 | - '<br/>' . $this->getSlogan(); |
|
125 | + '<br/>'.$this->getSlogan(); |
|
126 | 126 | |
127 | 127 | return $footer; |
128 | 128 | } |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function getLongFooter() { |
135 | 135 | $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
136 | - '<br/>' . $this->getSlogan(); |
|
136 | + '<br/>'.$this->getSlogan(); |
|
137 | 137 | |
138 | 138 | return $footer; |
139 | 139 | } |
140 | 140 | |
141 | 141 | public function buildDocLinkToKey($key) { |
142 | - return $this->getDocBaseUrl() . '/server/12/go.php?to=' . $key; |
|
142 | + return $this->getDocBaseUrl().'/server/12/go.php?to='.$key; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |
@@ -20,114 +20,114 @@ |
||
20 | 20 | |
21 | 21 | class OC_Theme { |
22 | 22 | |
23 | - /** |
|
24 | - * Returns the base URL |
|
25 | - * @return string URL |
|
26 | - */ |
|
27 | - public function getBaseUrl() { |
|
28 | - return 'https://nextcloud.com'; |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Returns the documentation URL |
|
33 | - * @return string URL |
|
34 | - */ |
|
35 | - public function getDocBaseUrl() { |
|
36 | - return 'https://docs.nextcloud.com'; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Returns the title |
|
41 | - * @return string title |
|
42 | - */ |
|
43 | - public function getTitle() { |
|
44 | - return 'Custom Cloud'; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Returns the short name of the software |
|
49 | - * @return string title |
|
50 | - */ |
|
51 | - public function getName() { |
|
52 | - return 'Custom Cloud'; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Returns the short name of the software containing HTML strings |
|
57 | - * @return string title |
|
58 | - */ |
|
59 | - public function getHTMLName() { |
|
60 | - return 'Custom Cloud'; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
65 | - * @return string entity name |
|
66 | - */ |
|
67 | - public function getEntity() { |
|
68 | - return 'Custom Cloud Co.'; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Returns slogan |
|
73 | - * @return string slogan |
|
74 | - */ |
|
75 | - public function getSlogan() { |
|
76 | - return 'Your custom cloud, personalized for you!'; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Returns logo claim |
|
81 | - * @return string logo claim |
|
82 | - * @deprecated 13.0.0 not used anymore |
|
83 | - */ |
|
84 | - public function getLogoClaim() { |
|
85 | - return ''; |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns short version of the footer |
|
90 | - * @return string short footer |
|
91 | - */ |
|
92 | - public function getShortFooter() { |
|
93 | - $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
94 | - '<br/>' . $this->getSlogan(); |
|
95 | - |
|
96 | - return $footer; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Returns long version of the footer |
|
101 | - * @return string long footer |
|
102 | - */ |
|
103 | - public function getLongFooter() { |
|
104 | - $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
105 | - '<br/>' . $this->getSlogan(); |
|
106 | - |
|
107 | - return $footer; |
|
108 | - } |
|
109 | - |
|
110 | - public function buildDocLinkToKey($key) { |
|
111 | - return $this->getDocBaseUrl() . '/server/12/go.php?to=' . $key; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Returns mail header color |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function getColorPrimary() { |
|
120 | - return '#745bca'; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Returns variables to overload defaults from core/css/variables.scss |
|
125 | - * @return array |
|
126 | - */ |
|
127 | - public function getScssVariables() { |
|
128 | - return [ |
|
129 | - 'color-primary' => '#745bca' |
|
130 | - ]; |
|
131 | - } |
|
23 | + /** |
|
24 | + * Returns the base URL |
|
25 | + * @return string URL |
|
26 | + */ |
|
27 | + public function getBaseUrl() { |
|
28 | + return 'https://nextcloud.com'; |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Returns the documentation URL |
|
33 | + * @return string URL |
|
34 | + */ |
|
35 | + public function getDocBaseUrl() { |
|
36 | + return 'https://docs.nextcloud.com'; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Returns the title |
|
41 | + * @return string title |
|
42 | + */ |
|
43 | + public function getTitle() { |
|
44 | + return 'Custom Cloud'; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Returns the short name of the software |
|
49 | + * @return string title |
|
50 | + */ |
|
51 | + public function getName() { |
|
52 | + return 'Custom Cloud'; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Returns the short name of the software containing HTML strings |
|
57 | + * @return string title |
|
58 | + */ |
|
59 | + public function getHTMLName() { |
|
60 | + return 'Custom Cloud'; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
65 | + * @return string entity name |
|
66 | + */ |
|
67 | + public function getEntity() { |
|
68 | + return 'Custom Cloud Co.'; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Returns slogan |
|
73 | + * @return string slogan |
|
74 | + */ |
|
75 | + public function getSlogan() { |
|
76 | + return 'Your custom cloud, personalized for you!'; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Returns logo claim |
|
81 | + * @return string logo claim |
|
82 | + * @deprecated 13.0.0 not used anymore |
|
83 | + */ |
|
84 | + public function getLogoClaim() { |
|
85 | + return ''; |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns short version of the footer |
|
90 | + * @return string short footer |
|
91 | + */ |
|
92 | + public function getShortFooter() { |
|
93 | + $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
94 | + '<br/>' . $this->getSlogan(); |
|
95 | + |
|
96 | + return $footer; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Returns long version of the footer |
|
101 | + * @return string long footer |
|
102 | + */ |
|
103 | + public function getLongFooter() { |
|
104 | + $footer = '© 2017 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
105 | + '<br/>' . $this->getSlogan(); |
|
106 | + |
|
107 | + return $footer; |
|
108 | + } |
|
109 | + |
|
110 | + public function buildDocLinkToKey($key) { |
|
111 | + return $this->getDocBaseUrl() . '/server/12/go.php?to=' . $key; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Returns mail header color |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function getColorPrimary() { |
|
120 | + return '#745bca'; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Returns variables to overload defaults from core/css/variables.scss |
|
125 | + * @return array |
|
126 | + */ |
|
127 | + public function getScssVariables() { |
|
128 | + return [ |
|
129 | + 'color-primary' => '#745bca' |
|
130 | + ]; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |