@@ -29,15 +29,15 @@ |
||
29 | 29 | namespace OCA\AdminAudit\Actions; |
30 | 30 | |
31 | 31 | class Trashbin extends Action { |
32 | - public function delete(array $params): void { |
|
33 | - $this->log('File "%s" deleted from trash bin.', |
|
34 | - ['path' => $params['path']], ['path'] |
|
35 | - ); |
|
36 | - } |
|
32 | + public function delete(array $params): void { |
|
33 | + $this->log('File "%s" deleted from trash bin.', |
|
34 | + ['path' => $params['path']], ['path'] |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - public function restore(array $params): void { |
|
39 | - $this->log('File "%s" restored from trash bin.', |
|
40 | - ['path' => $params['filePath']], ['path'] |
|
41 | - ); |
|
42 | - } |
|
38 | + public function restore(array $params): void { |
|
39 | + $this->log('File "%s" restored from trash bin.', |
|
40 | + ['path' => $params['filePath']], ['path'] |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | } |
@@ -29,22 +29,22 @@ |
||
29 | 29 | * @since 22.0.0 |
30 | 30 | */ |
31 | 31 | class AlreadySharedException extends GenericShareException { |
32 | - /** @var IShare */ |
|
33 | - private $existingShare; |
|
32 | + /** @var IShare */ |
|
33 | + private $existingShare; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @since 22.0.0 |
|
37 | - */ |
|
38 | - public function __construct(string $message, IShare $existingShare) { |
|
39 | - parent::__construct($message); |
|
35 | + /** |
|
36 | + * @since 22.0.0 |
|
37 | + */ |
|
38 | + public function __construct(string $message, IShare $existingShare) { |
|
39 | + parent::__construct($message); |
|
40 | 40 | |
41 | - $this->existingShare = $existingShare; |
|
42 | - } |
|
41 | + $this->existingShare = $existingShare; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @since 22.0.0 |
|
46 | - */ |
|
47 | - public function getExistingShare(): IShare { |
|
48 | - return $this->existingShare; |
|
49 | - } |
|
44 | + /** |
|
45 | + * @since 22.0.0 |
|
46 | + */ |
|
47 | + public function getExistingShare(): IShare { |
|
48 | + return $this->existingShare; |
|
49 | + } |
|
50 | 50 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function register(IRegistrationContext $context): void { |
61 | 61 | $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); |
62 | 62 | |
63 | - $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) { |
|
63 | + $context->registerService(NewUserMailHelper::class, function(ContainerInterface $c) { |
|
64 | 64 | return new NewUserMailHelper( |
65 | 65 | $c->get(Defaults::class), |
66 | 66 | $c->get(IURLGenerator::class), |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | Util::getDefaultEmailAddress('no-reply') |
74 | 74 | ); |
75 | 75 | }); |
76 | - $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) { |
|
76 | + $context->registerService(ProvisioningApiMiddleware::class, function(ContainerInterface $c) { |
|
77 | 77 | $user = $c->get(IUserManager::class)->get($c->get('UserId')); |
78 | 78 | $isAdmin = false; |
79 | 79 | $isSubAdmin = false; |
@@ -54,48 +54,48 @@ |
||
54 | 54 | use Psr\Container\ContainerInterface; |
55 | 55 | |
56 | 56 | class Application extends App implements IBootstrap { |
57 | - public function __construct(array $urlParams = []) { |
|
58 | - parent::__construct('provisioning_api', $urlParams); |
|
59 | - } |
|
57 | + public function __construct(array $urlParams = []) { |
|
58 | + parent::__construct('provisioning_api', $urlParams); |
|
59 | + } |
|
60 | 60 | |
61 | - public function register(IRegistrationContext $context): void { |
|
62 | - $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); |
|
61 | + public function register(IRegistrationContext $context): void { |
|
62 | + $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); |
|
63 | 63 | |
64 | - $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) { |
|
65 | - return new NewUserMailHelper( |
|
66 | - $c->get(Defaults::class), |
|
67 | - $c->get(IURLGenerator::class), |
|
68 | - $c->get(IFactory::class), |
|
69 | - $c->get(IMailer::class), |
|
70 | - $c->get(ISecureRandom::class), |
|
71 | - $c->get(ITimeFactory::class), |
|
72 | - $c->get(IConfig::class), |
|
73 | - $c->get(ICrypto::class), |
|
74 | - Util::getDefaultEmailAddress('no-reply') |
|
75 | - ); |
|
76 | - }); |
|
77 | - $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) { |
|
78 | - $user = $c->get(IUserManager::class)->get($c->get('UserId')); |
|
79 | - $isAdmin = false; |
|
80 | - $isSubAdmin = false; |
|
64 | + $context->registerService(NewUserMailHelper::class, function (ContainerInterface $c) { |
|
65 | + return new NewUserMailHelper( |
|
66 | + $c->get(Defaults::class), |
|
67 | + $c->get(IURLGenerator::class), |
|
68 | + $c->get(IFactory::class), |
|
69 | + $c->get(IMailer::class), |
|
70 | + $c->get(ISecureRandom::class), |
|
71 | + $c->get(ITimeFactory::class), |
|
72 | + $c->get(IConfig::class), |
|
73 | + $c->get(ICrypto::class), |
|
74 | + Util::getDefaultEmailAddress('no-reply') |
|
75 | + ); |
|
76 | + }); |
|
77 | + $context->registerService(ProvisioningApiMiddleware::class, function (ContainerInterface $c) { |
|
78 | + $user = $c->get(IUserManager::class)->get($c->get('UserId')); |
|
79 | + $isAdmin = false; |
|
80 | + $isSubAdmin = false; |
|
81 | 81 | |
82 | - if ($user instanceof IUser) { |
|
83 | - $groupManager = $c->get(IGroupManager::class); |
|
84 | - assert($groupManager instanceof GroupManager); |
|
85 | - $isAdmin = $groupManager->isAdmin($user->getUID()); |
|
86 | - $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user); |
|
87 | - } |
|
82 | + if ($user instanceof IUser) { |
|
83 | + $groupManager = $c->get(IGroupManager::class); |
|
84 | + assert($groupManager instanceof GroupManager); |
|
85 | + $isAdmin = $groupManager->isAdmin($user->getUID()); |
|
86 | + $isSubAdmin = $groupManager->getSubAdmin()->isSubAdmin($user); |
|
87 | + } |
|
88 | 88 | |
89 | - return new ProvisioningApiMiddleware( |
|
90 | - $c->get(IControllerMethodReflector::class), |
|
91 | - $isAdmin, |
|
92 | - $isSubAdmin |
|
93 | - ); |
|
94 | - }); |
|
95 | - $context->registerMiddleware(ProvisioningApiMiddleware::class); |
|
96 | - $context->registerCapability(Capabilities::class); |
|
97 | - } |
|
89 | + return new ProvisioningApiMiddleware( |
|
90 | + $c->get(IControllerMethodReflector::class), |
|
91 | + $isAdmin, |
|
92 | + $isSubAdmin |
|
93 | + ); |
|
94 | + }); |
|
95 | + $context->registerMiddleware(ProvisioningApiMiddleware::class); |
|
96 | + $context->registerCapability(Capabilities::class); |
|
97 | + } |
|
98 | 98 | |
99 | - public function boot(IBootContext $context): void { |
|
100 | - } |
|
99 | + public function boot(IBootContext $context): void { |
|
100 | + } |
|
101 | 101 | } |
@@ -30,31 +30,31 @@ |
||
30 | 30 | * Fallback implementation for moveFromCache |
31 | 31 | */ |
32 | 32 | trait MoveFromCacheTrait { |
33 | - /** |
|
34 | - * store meta data for a file or folder |
|
35 | - * |
|
36 | - * @param string $file |
|
37 | - * @param array $data |
|
38 | - * |
|
39 | - * @return int file id |
|
40 | - * @throws \RuntimeException |
|
41 | - */ |
|
42 | - abstract public function put($file, array $data); |
|
33 | + /** |
|
34 | + * store meta data for a file or folder |
|
35 | + * |
|
36 | + * @param string $file |
|
37 | + * @param array $data |
|
38 | + * |
|
39 | + * @return int file id |
|
40 | + * @throws \RuntimeException |
|
41 | + */ |
|
42 | + abstract public function put($file, array $data); |
|
43 | 43 | |
44 | - abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; |
|
44 | + abstract public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Move a file or folder in the cache |
|
48 | - * |
|
49 | - * @param \OCP\Files\Cache\ICache $sourceCache |
|
50 | - * @param string $sourcePath |
|
51 | - * @param string $targetPath |
|
52 | - */ |
|
53 | - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
54 | - $sourceEntry = $sourceCache->get($sourcePath); |
|
46 | + /** |
|
47 | + * Move a file or folder in the cache |
|
48 | + * |
|
49 | + * @param \OCP\Files\Cache\ICache $sourceCache |
|
50 | + * @param string $sourcePath |
|
51 | + * @param string $targetPath |
|
52 | + */ |
|
53 | + public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { |
|
54 | + $sourceEntry = $sourceCache->get($sourcePath); |
|
55 | 55 | |
56 | - $this->copyFromCache($sourceCache, $sourceEntry, $targetPath); |
|
56 | + $this->copyFromCache($sourceCache, $sourceEntry, $targetPath); |
|
57 | 57 | |
58 | - $sourceCache->remove($sourcePath); |
|
59 | - } |
|
58 | + $sourceCache->remove($sourcePath); |
|
59 | + } |
|
60 | 60 | } |
@@ -31,22 +31,22 @@ |
||
31 | 31 | use OCP\Migration\SimpleMigrationStep; |
32 | 32 | |
33 | 33 | class Version21000Date20210309185127 extends SimpleMigrationStep { |
34 | - /** |
|
35 | - * @param IOutput $output |
|
36 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | - * @param array $options |
|
38 | - * @return null|ISchemaWrapper |
|
39 | - */ |
|
40 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
41 | - /** @var ISchemaWrapper $schema */ |
|
42 | - $schema = $schemaClosure(); |
|
34 | + /** |
|
35 | + * @param IOutput $output |
|
36 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
37 | + * @param array $options |
|
38 | + * @return null|ISchemaWrapper |
|
39 | + */ |
|
40 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
41 | + /** @var ISchemaWrapper $schema */ |
|
42 | + $schema = $schemaClosure(); |
|
43 | 43 | |
44 | - $table = $schema->getTable('known_users'); |
|
45 | - if (!$table->hasIndex('ku_known_user')) { |
|
46 | - $table->addIndex(['known_user'], 'ku_known_user'); |
|
47 | - return $schema; |
|
48 | - } |
|
44 | + $table = $schema->getTable('known_users'); |
|
45 | + if (!$table->hasIndex('ku_known_user')) { |
|
46 | + $table->addIndex(['known_user'], 'ku_known_user'); |
|
47 | + return $schema; |
|
48 | + } |
|
49 | 49 | |
50 | - return null; |
|
51 | - } |
|
50 | + return null; |
|
51 | + } |
|
52 | 52 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $avatarsToDeleteCount = 0; |
96 | 96 | |
97 | 97 | foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) { |
98 | - $output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE); |
|
98 | + $output->writeln('Deleting avatar for '.$userId, OutputInterface::VERBOSITY_VERBOSE); |
|
99 | 99 | |
100 | 100 | $avatarsToDeleteCount++; |
101 | 101 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - $output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars'); |
|
115 | + $output->writeln('Deleted '.$avatarsToDeleteCount.' avatars'); |
|
116 | 116 | $output->writeln(''); |
117 | 117 | } |
118 | 118 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $previewsToDeleteCount = 0; |
131 | 131 | |
132 | 132 | foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) { |
133 | - $output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE); |
|
133 | + $output->writeln('Deleting previews for '.$filePath, OutputInterface::VERBOSITY_VERBOSE); |
|
134 | 134 | |
135 | 135 | $previewsToDeleteCount++; |
136 | 136 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | try { |
142 | - $preview = $this->previewFolder->getFolder((string)$previewFileId); |
|
142 | + $preview = $this->previewFolder->getFolder((string) $previewFileId); |
|
143 | 143 | $preview->delete(); |
144 | 144 | } catch (NotFoundException $e) { |
145 | 145 | // continue |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | - $output->writeln('Deleted ' . $previewsToDeleteCount . ' previews'); |
|
151 | + $output->writeln('Deleted '.$previewsToDeleteCount.' previews'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | // Copy pasted and adjusted from |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * We take the md5 of the name (fileid) and split the first 7 chars. That way |
172 | 172 | * there are not a gazillion files in the root of the preview appdata. |
173 | 173 | */ |
174 | - $like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%'; |
|
174 | + $like = $this->connection->escapeLikeParameter($data['path']).'/_/_/_/_/_/_/_/%'; |
|
175 | 175 | |
176 | 176 | $qb = $this->connection->getQueryBuilder(); |
177 | 177 | $qb->select('a.name', 'b.path') |
@@ -22,143 +22,143 @@ |
||
22 | 22 | use Symfony\Component\Console\Output\OutputInterface; |
23 | 23 | |
24 | 24 | class ResetRenderedTexts extends Command { |
25 | - public function __construct( |
|
26 | - protected IDBConnection $connection, |
|
27 | - protected IUserManager $userManager, |
|
28 | - protected IAvatarManager $avatarManager, |
|
29 | - private Root $previewFolder, |
|
30 | - private IMimeTypeLoader $mimeTypeLoader, |
|
31 | - ) { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
34 | - |
|
35 | - protected function configure() { |
|
36 | - $this |
|
37 | - ->setName('preview:reset-rendered-texts') |
|
38 | - ->setDescription('Deletes all generated avatars and previews of text and md files') |
|
39 | - ->addOption('dry', 'd', InputOption::VALUE_NONE, 'Dry mode - will not delete any files - in combination with the verbose mode one could check the operations.'); |
|
40 | - } |
|
41 | - |
|
42 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
43 | - $dryMode = $input->getOption('dry'); |
|
44 | - |
|
45 | - if ($dryMode) { |
|
46 | - $output->writeln('INFO: The command is run in dry mode and will not modify anything.'); |
|
47 | - $output->writeln(''); |
|
48 | - } |
|
49 | - |
|
50 | - $this->deleteAvatars($output, $dryMode); |
|
51 | - $this->deletePreviews($output, $dryMode); |
|
52 | - |
|
53 | - return 0; |
|
54 | - } |
|
55 | - |
|
56 | - private function deleteAvatars(OutputInterface $output, bool $dryMode): void { |
|
57 | - $avatarsToDeleteCount = 0; |
|
58 | - |
|
59 | - foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) { |
|
60 | - $output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE); |
|
61 | - |
|
62 | - $avatarsToDeleteCount++; |
|
63 | - |
|
64 | - if ($dryMode) { |
|
65 | - continue; |
|
66 | - } |
|
67 | - |
|
68 | - try { |
|
69 | - $avatar->remove(); |
|
70 | - } catch (NotFoundException $e) { |
|
71 | - // continue |
|
72 | - } catch (NotPermittedException $e) { |
|
73 | - // continue |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - $output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars'); |
|
78 | - $output->writeln(''); |
|
79 | - } |
|
80 | - |
|
81 | - private function getAvatarsToDelete(): \Iterator { |
|
82 | - foreach ($this->userManager->search('') as $user) { |
|
83 | - $avatar = $this->avatarManager->getAvatar($user->getUID()); |
|
84 | - |
|
85 | - if (!$avatar->isCustomAvatar()) { |
|
86 | - yield [$user->getUID(), $avatar]; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - private function deletePreviews(OutputInterface $output, bool $dryMode): void { |
|
92 | - $previewsToDeleteCount = 0; |
|
93 | - |
|
94 | - foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) { |
|
95 | - $output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE); |
|
96 | - |
|
97 | - $previewsToDeleteCount++; |
|
98 | - |
|
99 | - if ($dryMode) { |
|
100 | - continue; |
|
101 | - } |
|
102 | - |
|
103 | - try { |
|
104 | - $preview = $this->previewFolder->getFolder((string)$previewFileId); |
|
105 | - $preview->delete(); |
|
106 | - } catch (NotFoundException $e) { |
|
107 | - // continue |
|
108 | - } catch (NotPermittedException $e) { |
|
109 | - // continue |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - $output->writeln('Deleted ' . $previewsToDeleteCount . ' previews'); |
|
114 | - } |
|
115 | - |
|
116 | - // Copy pasted and adjusted from |
|
117 | - // "lib/private/Preview/BackgroundCleanupJob.php". |
|
118 | - private function getPreviewsToDelete(): \Iterator { |
|
119 | - $qb = $this->connection->getQueryBuilder(); |
|
120 | - $qb->select('path', 'mimetype') |
|
121 | - ->from('filecache') |
|
122 | - ->where($qb->expr()->eq('fileid', $qb->createNamedParameter($this->previewFolder->getId()))); |
|
123 | - $cursor = $qb->executeQuery(); |
|
124 | - $data = $cursor->fetch(); |
|
125 | - $cursor->closeCursor(); |
|
126 | - |
|
127 | - if ($data === null) { |
|
128 | - return []; |
|
129 | - } |
|
130 | - |
|
131 | - /* |
|
25 | + public function __construct( |
|
26 | + protected IDBConnection $connection, |
|
27 | + protected IUserManager $userManager, |
|
28 | + protected IAvatarManager $avatarManager, |
|
29 | + private Root $previewFolder, |
|
30 | + private IMimeTypeLoader $mimeTypeLoader, |
|
31 | + ) { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | + |
|
35 | + protected function configure() { |
|
36 | + $this |
|
37 | + ->setName('preview:reset-rendered-texts') |
|
38 | + ->setDescription('Deletes all generated avatars and previews of text and md files') |
|
39 | + ->addOption('dry', 'd', InputOption::VALUE_NONE, 'Dry mode - will not delete any files - in combination with the verbose mode one could check the operations.'); |
|
40 | + } |
|
41 | + |
|
42 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
43 | + $dryMode = $input->getOption('dry'); |
|
44 | + |
|
45 | + if ($dryMode) { |
|
46 | + $output->writeln('INFO: The command is run in dry mode and will not modify anything.'); |
|
47 | + $output->writeln(''); |
|
48 | + } |
|
49 | + |
|
50 | + $this->deleteAvatars($output, $dryMode); |
|
51 | + $this->deletePreviews($output, $dryMode); |
|
52 | + |
|
53 | + return 0; |
|
54 | + } |
|
55 | + |
|
56 | + private function deleteAvatars(OutputInterface $output, bool $dryMode): void { |
|
57 | + $avatarsToDeleteCount = 0; |
|
58 | + |
|
59 | + foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) { |
|
60 | + $output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE); |
|
61 | + |
|
62 | + $avatarsToDeleteCount++; |
|
63 | + |
|
64 | + if ($dryMode) { |
|
65 | + continue; |
|
66 | + } |
|
67 | + |
|
68 | + try { |
|
69 | + $avatar->remove(); |
|
70 | + } catch (NotFoundException $e) { |
|
71 | + // continue |
|
72 | + } catch (NotPermittedException $e) { |
|
73 | + // continue |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + $output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars'); |
|
78 | + $output->writeln(''); |
|
79 | + } |
|
80 | + |
|
81 | + private function getAvatarsToDelete(): \Iterator { |
|
82 | + foreach ($this->userManager->search('') as $user) { |
|
83 | + $avatar = $this->avatarManager->getAvatar($user->getUID()); |
|
84 | + |
|
85 | + if (!$avatar->isCustomAvatar()) { |
|
86 | + yield [$user->getUID(), $avatar]; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + private function deletePreviews(OutputInterface $output, bool $dryMode): void { |
|
92 | + $previewsToDeleteCount = 0; |
|
93 | + |
|
94 | + foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) { |
|
95 | + $output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE); |
|
96 | + |
|
97 | + $previewsToDeleteCount++; |
|
98 | + |
|
99 | + if ($dryMode) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + |
|
103 | + try { |
|
104 | + $preview = $this->previewFolder->getFolder((string)$previewFileId); |
|
105 | + $preview->delete(); |
|
106 | + } catch (NotFoundException $e) { |
|
107 | + // continue |
|
108 | + } catch (NotPermittedException $e) { |
|
109 | + // continue |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + $output->writeln('Deleted ' . $previewsToDeleteCount . ' previews'); |
|
114 | + } |
|
115 | + |
|
116 | + // Copy pasted and adjusted from |
|
117 | + // "lib/private/Preview/BackgroundCleanupJob.php". |
|
118 | + private function getPreviewsToDelete(): \Iterator { |
|
119 | + $qb = $this->connection->getQueryBuilder(); |
|
120 | + $qb->select('path', 'mimetype') |
|
121 | + ->from('filecache') |
|
122 | + ->where($qb->expr()->eq('fileid', $qb->createNamedParameter($this->previewFolder->getId()))); |
|
123 | + $cursor = $qb->executeQuery(); |
|
124 | + $data = $cursor->fetch(); |
|
125 | + $cursor->closeCursor(); |
|
126 | + |
|
127 | + if ($data === null) { |
|
128 | + return []; |
|
129 | + } |
|
130 | + |
|
131 | + /* |
|
132 | 132 | * This lovely like is the result of the way the new previews are stored |
133 | 133 | * We take the md5 of the name (fileid) and split the first 7 chars. That way |
134 | 134 | * there are not a gazillion files in the root of the preview appdata. |
135 | 135 | */ |
136 | - $like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%'; |
|
137 | - |
|
138 | - $qb = $this->connection->getQueryBuilder(); |
|
139 | - $qb->select('a.name', 'b.path') |
|
140 | - ->from('filecache', 'a') |
|
141 | - ->leftJoin('a', 'filecache', 'b', $qb->expr()->eq( |
|
142 | - $qb->expr()->castColumn('a.name', IQueryBuilder::PARAM_INT), 'b.fileid' |
|
143 | - )) |
|
144 | - ->where( |
|
145 | - $qb->expr()->andX( |
|
146 | - $qb->expr()->like('a.path', $qb->createNamedParameter($like)), |
|
147 | - $qb->expr()->eq('a.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('httpd/unix-directory'))), |
|
148 | - $qb->expr()->orX( |
|
149 | - $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/plain'))), |
|
150 | - $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/markdown'))), |
|
151 | - $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/x-markdown'))) |
|
152 | - ) |
|
153 | - ) |
|
154 | - ); |
|
155 | - |
|
156 | - $cursor = $qb->executeQuery(); |
|
157 | - |
|
158 | - while ($row = $cursor->fetch()) { |
|
159 | - yield $row; |
|
160 | - } |
|
161 | - |
|
162 | - $cursor->closeCursor(); |
|
163 | - } |
|
136 | + $like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%'; |
|
137 | + |
|
138 | + $qb = $this->connection->getQueryBuilder(); |
|
139 | + $qb->select('a.name', 'b.path') |
|
140 | + ->from('filecache', 'a') |
|
141 | + ->leftJoin('a', 'filecache', 'b', $qb->expr()->eq( |
|
142 | + $qb->expr()->castColumn('a.name', IQueryBuilder::PARAM_INT), 'b.fileid' |
|
143 | + )) |
|
144 | + ->where( |
|
145 | + $qb->expr()->andX( |
|
146 | + $qb->expr()->like('a.path', $qb->createNamedParameter($like)), |
|
147 | + $qb->expr()->eq('a.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('httpd/unix-directory'))), |
|
148 | + $qb->expr()->orX( |
|
149 | + $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/plain'))), |
|
150 | + $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/markdown'))), |
|
151 | + $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/x-markdown'))) |
|
152 | + ) |
|
153 | + ) |
|
154 | + ); |
|
155 | + |
|
156 | + $cursor = $qb->executeQuery(); |
|
157 | + |
|
158 | + while ($row = $cursor->fetch()) { |
|
159 | + yield $row; |
|
160 | + } |
|
161 | + |
|
162 | + $cursor->closeCursor(); |
|
163 | + } |
|
164 | 164 | } |
@@ -43,6 +43,6 @@ |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getData(): int { |
46 | - return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10'); |
|
46 | + return (int) $this->config->getAppValue('comments', 'maxAutoCompleteResults', '10'); |
|
47 | 47 | } |
48 | 48 | } |
@@ -12,16 +12,16 @@ |
||
12 | 12 | use OCP\IConfig; |
13 | 13 | |
14 | 14 | class MaxAutoCompleteResultsInitialState extends InitialStateProvider { |
15 | - public function __construct( |
|
16 | - private IConfig $config, |
|
17 | - ) { |
|
18 | - } |
|
15 | + public function __construct( |
|
16 | + private IConfig $config, |
|
17 | + ) { |
|
18 | + } |
|
19 | 19 | |
20 | - public function getKey(): string { |
|
21 | - return 'maxAutoCompleteResults'; |
|
22 | - } |
|
20 | + public function getKey(): string { |
|
21 | + return 'maxAutoCompleteResults'; |
|
22 | + } |
|
23 | 23 | |
24 | - public function getData(): int { |
|
25 | - return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10'); |
|
26 | - } |
|
24 | + public function getData(): int { |
|
25 | + return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10'); |
|
26 | + } |
|
27 | 27 | } |
@@ -36,27 +36,27 @@ |
||
36 | 36 | |
37 | 37 | class Version1002Date20170919123342 extends SimpleMigrationStep { |
38 | 38 | |
39 | - /** |
|
40 | - * @param IOutput $output |
|
41 | - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | - * @param array $options |
|
43 | - * @return null|ISchemaWrapper |
|
44 | - * @since 13.0.0 |
|
45 | - */ |
|
46 | - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
47 | - /** @var ISchemaWrapper $schema */ |
|
48 | - $schema = $schemaClosure(); |
|
49 | - |
|
50 | - $table = $schema->getTable('twofactor_backupcodes'); |
|
51 | - $column = $table->getColumn('user_id'); |
|
52 | - $column->setDefault(''); |
|
53 | - |
|
54 | - $column = $table->getColumn('used'); |
|
55 | - if ($column->getType()->getName() !== Types::SMALLINT) { |
|
56 | - $column->setType(Type::getType(Types::SMALLINT)); |
|
57 | - $column->setOptions(['length' => 6]); |
|
58 | - } |
|
59 | - |
|
60 | - return $schema; |
|
61 | - } |
|
39 | + /** |
|
40 | + * @param IOutput $output |
|
41 | + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
42 | + * @param array $options |
|
43 | + * @return null|ISchemaWrapper |
|
44 | + * @since 13.0.0 |
|
45 | + */ |
|
46 | + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { |
|
47 | + /** @var ISchemaWrapper $schema */ |
|
48 | + $schema = $schemaClosure(); |
|
49 | + |
|
50 | + $table = $schema->getTable('twofactor_backupcodes'); |
|
51 | + $column = $table->getColumn('user_id'); |
|
52 | + $column->setDefault(''); |
|
53 | + |
|
54 | + $column = $table->getColumn('used'); |
|
55 | + if ($column->getType()->getName() !== Types::SMALLINT) { |
|
56 | + $column->setType(Type::getType(Types::SMALLINT)); |
|
57 | + $column->setOptions(['length' => 6]); |
|
58 | + } |
|
59 | + |
|
60 | + return $schema; |
|
61 | + } |
|
62 | 62 | } |
@@ -6,51 +6,51 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitTwoFactorBackupCodes |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'O' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'OCA\\TwoFactorBackupCodes\\' => 25, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'OCA\\TwoFactorBackupCodes\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/..'.'/../lib', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
25 | - 'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php', |
|
26 | - 'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
27 | - 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => __DIR__ . '/..' . '/../lib/BackgroundJob/CheckBackupCodes.php', |
|
28 | - 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RememberBackupCodesJob.php', |
|
29 | - 'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php', |
|
30 | - 'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__ . '/..' . '/../lib/Db/BackupCode.php', |
|
31 | - 'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__ . '/..' . '/../lib/Db/BackupCodeMapper.php', |
|
32 | - 'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__ . '/..' . '/../lib/Event/CodesGenerated.php', |
|
33 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__ . '/..' . '/../lib/Listener/ActivityPublisher.php', |
|
34 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__ . '/..' . '/../lib/Listener/ClearNotifications.php', |
|
35 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => __DIR__ . '/..' . '/../lib/Listener/ProviderDisabled.php', |
|
36 | - 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__ . '/..' . '/../lib/Listener/ProviderEnabled.php', |
|
37 | - 'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__ . '/..' . '/../lib/Listener/RegistryUpdater.php', |
|
38 | - 'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => __DIR__ . '/..' . '/../lib/Listener/UserDeleted.php', |
|
39 | - 'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => __DIR__ . '/..' . '/../lib/Migration/CheckBackupCodes.php', |
|
40 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607104347.php', |
|
41 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607113030.php', |
|
42 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170919123342.php', |
|
43 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170926101419.php', |
|
44 | - 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20180821043638.php', |
|
45 | - 'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__ . '/..' . '/../lib/Notifications/Notifier.php', |
|
46 | - 'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__ . '/..' . '/../lib/Provider/BackupCodesProvider.php', |
|
47 | - 'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__ . '/..' . '/../lib/Service/BackupCodeStorage.php', |
|
48 | - 'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
25 | + 'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php', |
|
26 | + 'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
27 | + 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => __DIR__.'/..'.'/../lib/BackgroundJob/CheckBackupCodes.php', |
|
28 | + 'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RememberBackupCodesJob.php', |
|
29 | + 'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php', |
|
30 | + 'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__.'/..'.'/../lib/Db/BackupCode.php', |
|
31 | + 'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__.'/..'.'/../lib/Db/BackupCodeMapper.php', |
|
32 | + 'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__.'/..'.'/../lib/Event/CodesGenerated.php', |
|
33 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__.'/..'.'/../lib/Listener/ActivityPublisher.php', |
|
34 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__.'/..'.'/../lib/Listener/ClearNotifications.php', |
|
35 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => __DIR__.'/..'.'/../lib/Listener/ProviderDisabled.php', |
|
36 | + 'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__.'/..'.'/../lib/Listener/ProviderEnabled.php', |
|
37 | + 'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__.'/..'.'/../lib/Listener/RegistryUpdater.php', |
|
38 | + 'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => __DIR__.'/..'.'/../lib/Listener/UserDeleted.php', |
|
39 | + 'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => __DIR__.'/..'.'/../lib/Migration/CheckBackupCodes.php', |
|
40 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607104347.php', |
|
41 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607113030.php', |
|
42 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170919123342.php', |
|
43 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170926101419.php', |
|
44 | + 'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20180821043638.php', |
|
45 | + 'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__.'/..'.'/../lib/Notifications/Notifier.php', |
|
46 | + 'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__.'/..'.'/../lib/Provider/BackupCodesProvider.php', |
|
47 | + 'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__.'/..'.'/../lib/Service/BackupCodeStorage.php', |
|
48 | + 'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php', |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | public static function getInitializer(ClassLoader $loader) |
52 | 52 | { |
53 | - return \Closure::bind(function () use ($loader) { |
|
53 | + return \Closure::bind(function() use ($loader) { |
|
54 | 54 | $loader->prefixLengthsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixLengthsPsr4; |
55 | 55 | $loader->prefixDirsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixDirsPsr4; |
56 | 56 | $loader->classMap = ComposerStaticInitTwoFactorBackupCodes::$classMap; |