@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | // no php execution timeout for webdav |
26 | 26 | if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
27 | - @set_time_limit(0); |
|
27 | + @set_time_limit(0); |
|
28 | 28 | } |
29 | 29 | ignore_user_abort(true); |
30 | 30 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | |
36 | 36 | $serverFactory = new \OCA\DAV\Direct\ServerFactory(\OC::$server->getConfig()); |
37 | 37 | $server = $serverFactory->createServer( |
38 | - $baseuri, |
|
39 | - $requestUri, |
|
40 | - \OC::$server->getRootFolder(), |
|
41 | - \OC::$server->query(\OCA\DAV\Db\DirectMapper::class), |
|
42 | - \OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class), |
|
43 | - \OC::$server->getBruteForceThrottler(), |
|
44 | - \OC::$server->getRequest() |
|
38 | + $baseuri, |
|
39 | + $requestUri, |
|
40 | + \OC::$server->getRootFolder(), |
|
41 | + \OC::$server->query(\OCA\DAV\Db\DirectMapper::class), |
|
42 | + \OC::$server->query(\OCP\AppFramework\Utility\ITimeFactory::class), |
|
43 | + \OC::$server->getBruteForceThrottler(), |
|
44 | + \OC::$server->getRequest() |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | $server->exec(); |
@@ -29,14 +29,14 @@ |
||
29 | 29 | |
30 | 30 | class Errorlog implements IWriter { |
31 | 31 | |
32 | - /** |
|
33 | - * write a message in the log |
|
34 | - * @param string $app |
|
35 | - * @param string $message |
|
36 | - * @param int $level |
|
37 | - */ |
|
38 | - public function write(string $app, $message, int $level) { |
|
39 | - error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | - } |
|
32 | + /** |
|
33 | + * write a message in the log |
|
34 | + * @param string $app |
|
35 | + * @param string $message |
|
36 | + * @param int $level |
|
37 | + */ |
|
38 | + public function write(string $app, $message, int $level) { |
|
39 | + error_log('[owncloud]['.$app.']['.$level.'] '.$message); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 |
@@ -30,8 +30,8 @@ |
||
30 | 30 | * @since 14.0.0 |
31 | 31 | */ |
32 | 32 | interface IWriter { |
33 | - /** |
|
34 | - * @since 14.0.0 |
|
35 | - */ |
|
36 | - public function write(string $app, $message, int $level); |
|
33 | + /** |
|
34 | + * @since 14.0.0 |
|
35 | + */ |
|
36 | + public function write(string $app, $message, int $level); |
|
37 | 37 | } |
@@ -31,13 +31,13 @@ |
||
31 | 31 | * @since 14.0.0 |
32 | 32 | */ |
33 | 33 | interface IFileBased { |
34 | - /** |
|
35 | - * @since 14.0.0 |
|
36 | - */ |
|
37 | - public function getLogFilePath():string; |
|
34 | + /** |
|
35 | + * @since 14.0.0 |
|
36 | + */ |
|
37 | + public function getLogFilePath():string; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @since 14.0.0 |
|
41 | - */ |
|
42 | - public function getEntries(int $limit=50, int $offset=0): array; |
|
39 | + /** |
|
40 | + * @since 14.0.0 |
|
41 | + */ |
|
42 | + public function getEntries(int $limit=50, int $offset=0): array; |
|
43 | 43 | } |
@@ -32,40 +32,40 @@ |
||
32 | 32 | */ |
33 | 33 | trait RotationTrait { |
34 | 34 | |
35 | - /** |
|
36 | - * @var string |
|
37 | - * @since 14.0.0 |
|
38 | - */ |
|
39 | - protected $filePath; |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + * @since 14.0.0 |
|
38 | + */ |
|
39 | + protected $filePath; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var int |
|
43 | - * @since 14.0.0 |
|
44 | - */ |
|
45 | - protected $maxSize; |
|
41 | + /** |
|
42 | + * @var int |
|
43 | + * @since 14.0.0 |
|
44 | + */ |
|
45 | + protected $maxSize; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string the resulting new filepath |
|
49 | - * @since 14.0.0 |
|
50 | - */ |
|
51 | - protected function rotate():string { |
|
52 | - $rotatedFile = $this->filePath.'.1'; |
|
53 | - rename($this->filePath, $rotatedFile); |
|
54 | - return $rotatedFile; |
|
55 | - } |
|
47 | + /** |
|
48 | + * @return string the resulting new filepath |
|
49 | + * @since 14.0.0 |
|
50 | + */ |
|
51 | + protected function rotate():string { |
|
52 | + $rotatedFile = $this->filePath.'.1'; |
|
53 | + rename($this->filePath, $rotatedFile); |
|
54 | + return $rotatedFile; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return bool |
|
59 | - * @since 14.0.0 |
|
60 | - */ |
|
61 | - protected function shouldRotateBySize():bool { |
|
62 | - if ((int)$this->maxSize > 0) { |
|
63 | - $filesize = @filesize($this->filePath); |
|
64 | - if ($filesize >= (int)$this->maxSize) { |
|
65 | - return true; |
|
66 | - } |
|
67 | - } |
|
68 | - return false; |
|
69 | - } |
|
57 | + /** |
|
58 | + * @return bool |
|
59 | + * @since 14.0.0 |
|
60 | + */ |
|
61 | + protected function shouldRotateBySize():bool { |
|
62 | + if ((int)$this->maxSize > 0) { |
|
63 | + $filesize = @filesize($this->filePath); |
|
64 | + if ($filesize >= (int)$this->maxSize) { |
|
65 | + return true; |
|
66 | + } |
|
67 | + } |
|
68 | + return false; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | } |
@@ -39,75 +39,75 @@ |
||
39 | 39 | |
40 | 40 | class DirectController extends OCSController { |
41 | 41 | |
42 | - /** @var IRootFolder */ |
|
43 | - private $rootFolder; |
|
42 | + /** @var IRootFolder */ |
|
43 | + private $rootFolder; |
|
44 | 44 | |
45 | - /** @var string */ |
|
46 | - private $userId; |
|
45 | + /** @var string */ |
|
46 | + private $userId; |
|
47 | 47 | |
48 | - /** @var DirectMapper */ |
|
49 | - private $mapper; |
|
48 | + /** @var DirectMapper */ |
|
49 | + private $mapper; |
|
50 | 50 | |
51 | - /** @var ISecureRandom */ |
|
52 | - private $random; |
|
51 | + /** @var ISecureRandom */ |
|
52 | + private $random; |
|
53 | 53 | |
54 | - /** @var ITimeFactory */ |
|
55 | - private $timeFactory; |
|
54 | + /** @var ITimeFactory */ |
|
55 | + private $timeFactory; |
|
56 | 56 | |
57 | - /** @var IURLGenerator */ |
|
58 | - private $urlGenerator; |
|
57 | + /** @var IURLGenerator */ |
|
58 | + private $urlGenerator; |
|
59 | 59 | |
60 | 60 | |
61 | - public function __construct(string $appName, |
|
62 | - IRequest $request, |
|
63 | - IRootFolder $rootFolder, |
|
64 | - string $userId, |
|
65 | - DirectMapper $mapper, |
|
66 | - ISecureRandom $random, |
|
67 | - ITimeFactory $timeFactory, |
|
68 | - IURLGenerator $urlGenerator) { |
|
69 | - parent::__construct($appName, $request); |
|
61 | + public function __construct(string $appName, |
|
62 | + IRequest $request, |
|
63 | + IRootFolder $rootFolder, |
|
64 | + string $userId, |
|
65 | + DirectMapper $mapper, |
|
66 | + ISecureRandom $random, |
|
67 | + ITimeFactory $timeFactory, |
|
68 | + IURLGenerator $urlGenerator) { |
|
69 | + parent::__construct($appName, $request); |
|
70 | 70 | |
71 | - $this->rootFolder = $rootFolder; |
|
72 | - $this->userId = $userId; |
|
73 | - $this->mapper = $mapper; |
|
74 | - $this->random = $random; |
|
75 | - $this->timeFactory = $timeFactory; |
|
76 | - $this->urlGenerator = $urlGenerator; |
|
77 | - } |
|
71 | + $this->rootFolder = $rootFolder; |
|
72 | + $this->userId = $userId; |
|
73 | + $this->mapper = $mapper; |
|
74 | + $this->random = $random; |
|
75 | + $this->timeFactory = $timeFactory; |
|
76 | + $this->urlGenerator = $urlGenerator; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * @NoAdminRequired |
|
81 | - */ |
|
82 | - public function getUrl(int $fileId): DataResponse { |
|
83 | - $userFolder = $this->rootFolder->getUserFolder($this->userId); |
|
79 | + /** |
|
80 | + * @NoAdminRequired |
|
81 | + */ |
|
82 | + public function getUrl(int $fileId): DataResponse { |
|
83 | + $userFolder = $this->rootFolder->getUserFolder($this->userId); |
|
84 | 84 | |
85 | - $files = $userFolder->getById($fileId); |
|
85 | + $files = $userFolder->getById($fileId); |
|
86 | 86 | |
87 | - if ($files === []) { |
|
88 | - throw new OCSNotFoundException(); |
|
89 | - } |
|
87 | + if ($files === []) { |
|
88 | + throw new OCSNotFoundException(); |
|
89 | + } |
|
90 | 90 | |
91 | - $file = array_shift($files); |
|
92 | - if (!($file instanceof File)) { |
|
93 | - throw new OCSBadRequestException('Direct download only works for files'); |
|
94 | - } |
|
91 | + $file = array_shift($files); |
|
92 | + if (!($file instanceof File)) { |
|
93 | + throw new OCSBadRequestException('Direct download only works for files'); |
|
94 | + } |
|
95 | 95 | |
96 | - //TODO: at some point we should use the directdownlaod function of storages |
|
97 | - $direct = new Direct(); |
|
98 | - $direct->setUserId($this->userId); |
|
99 | - $direct->setFileId($fileId); |
|
96 | + //TODO: at some point we should use the directdownlaod function of storages |
|
97 | + $direct = new Direct(); |
|
98 | + $direct->setUserId($this->userId); |
|
99 | + $direct->setFileId($fileId); |
|
100 | 100 | |
101 | - $token = $this->random->generate(60, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); |
|
102 | - $direct->setToken($token); |
|
103 | - $direct->setExpiration($this->timeFactory->getTime() + 60 * 60 * 8); |
|
101 | + $token = $this->random->generate(60, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); |
|
102 | + $direct->setToken($token); |
|
103 | + $direct->setExpiration($this->timeFactory->getTime() + 60 * 60 * 8); |
|
104 | 104 | |
105 | - $this->mapper->insert($direct); |
|
105 | + $this->mapper->insert($direct); |
|
106 | 106 | |
107 | - $url = $this->urlGenerator->getAbsoluteURL('remote.php/direct/'.$token); |
|
107 | + $url = $this->urlGenerator->getAbsoluteURL('remote.php/direct/'.$token); |
|
108 | 108 | |
109 | - return new DataResponse([ |
|
110 | - 'url' => $url, |
|
111 | - ]); |
|
112 | - } |
|
109 | + return new DataResponse([ |
|
110 | + 'url' => $url, |
|
111 | + ]); |
|
112 | + } |
|
113 | 113 | } |
@@ -37,82 +37,82 @@ |
||
37 | 37 | |
38 | 38 | class DirectHome implements ICollection { |
39 | 39 | |
40 | - /** @var IRootFolder */ |
|
41 | - private $rootFolder; |
|
42 | - |
|
43 | - /** @var DirectMapper */ |
|
44 | - private $mapper; |
|
45 | - |
|
46 | - /** @var ITimeFactory */ |
|
47 | - private $timeFactory; |
|
48 | - |
|
49 | - /** @var Throttler */ |
|
50 | - private $throttler; |
|
51 | - |
|
52 | - /** @var IRequest */ |
|
53 | - private $request; |
|
54 | - |
|
55 | - public function __construct(IRootFolder $rootFolder, |
|
56 | - DirectMapper $mapper, |
|
57 | - ITimeFactory $timeFactory, |
|
58 | - Throttler $throttler, |
|
59 | - IRequest $request) { |
|
60 | - $this->rootFolder = $rootFolder; |
|
61 | - $this->mapper = $mapper; |
|
62 | - $this->timeFactory = $timeFactory; |
|
63 | - $this->throttler = $throttler; |
|
64 | - $this->request = $request; |
|
65 | - } |
|
66 | - |
|
67 | - public function createFile($name, $data = null) { |
|
68 | - throw new Forbidden(); |
|
69 | - } |
|
70 | - |
|
71 | - public function createDirectory($name) { |
|
72 | - throw new Forbidden(); |
|
73 | - } |
|
74 | - |
|
75 | - public function getChild($name): DirectFile { |
|
76 | - try { |
|
77 | - $direct = $this->mapper->getByToken($name); |
|
78 | - |
|
79 | - // Expired |
|
80 | - if ($direct->getExpiration() < $this->timeFactory->getTime()) { |
|
81 | - throw new NotFound(); |
|
82 | - } |
|
83 | - |
|
84 | - return new DirectFile($direct, $this->rootFolder); |
|
85 | - } catch (DoesNotExistException $e) { |
|
86 | - // Since the token space is so huge only throttle on non exsisting token |
|
87 | - $this->throttler->registerAttempt('directlink', $this->request->getRemoteAddress()); |
|
88 | - $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'directlink'); |
|
89 | - |
|
90 | - throw new NotFound(); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - public function getChildren() { |
|
95 | - throw new MethodNotAllowed('Listing members of this collection is disabled'); |
|
96 | - } |
|
97 | - |
|
98 | - public function childExists($name): bool { |
|
99 | - return false; |
|
100 | - } |
|
101 | - |
|
102 | - public function delete() { |
|
103 | - throw new Forbidden(); |
|
104 | - } |
|
105 | - |
|
106 | - public function getName(): string { |
|
107 | - return 'direct'; |
|
108 | - } |
|
109 | - |
|
110 | - public function setName($name) { |
|
111 | - throw new Forbidden(); |
|
112 | - } |
|
113 | - |
|
114 | - public function getLastModified(): int { |
|
115 | - return 0; |
|
116 | - } |
|
40 | + /** @var IRootFolder */ |
|
41 | + private $rootFolder; |
|
42 | + |
|
43 | + /** @var DirectMapper */ |
|
44 | + private $mapper; |
|
45 | + |
|
46 | + /** @var ITimeFactory */ |
|
47 | + private $timeFactory; |
|
48 | + |
|
49 | + /** @var Throttler */ |
|
50 | + private $throttler; |
|
51 | + |
|
52 | + /** @var IRequest */ |
|
53 | + private $request; |
|
54 | + |
|
55 | + public function __construct(IRootFolder $rootFolder, |
|
56 | + DirectMapper $mapper, |
|
57 | + ITimeFactory $timeFactory, |
|
58 | + Throttler $throttler, |
|
59 | + IRequest $request) { |
|
60 | + $this->rootFolder = $rootFolder; |
|
61 | + $this->mapper = $mapper; |
|
62 | + $this->timeFactory = $timeFactory; |
|
63 | + $this->throttler = $throttler; |
|
64 | + $this->request = $request; |
|
65 | + } |
|
66 | + |
|
67 | + public function createFile($name, $data = null) { |
|
68 | + throw new Forbidden(); |
|
69 | + } |
|
70 | + |
|
71 | + public function createDirectory($name) { |
|
72 | + throw new Forbidden(); |
|
73 | + } |
|
74 | + |
|
75 | + public function getChild($name): DirectFile { |
|
76 | + try { |
|
77 | + $direct = $this->mapper->getByToken($name); |
|
78 | + |
|
79 | + // Expired |
|
80 | + if ($direct->getExpiration() < $this->timeFactory->getTime()) { |
|
81 | + throw new NotFound(); |
|
82 | + } |
|
83 | + |
|
84 | + return new DirectFile($direct, $this->rootFolder); |
|
85 | + } catch (DoesNotExistException $e) { |
|
86 | + // Since the token space is so huge only throttle on non exsisting token |
|
87 | + $this->throttler->registerAttempt('directlink', $this->request->getRemoteAddress()); |
|
88 | + $this->throttler->sleepDelay($this->request->getRemoteAddress(), 'directlink'); |
|
89 | + |
|
90 | + throw new NotFound(); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + public function getChildren() { |
|
95 | + throw new MethodNotAllowed('Listing members of this collection is disabled'); |
|
96 | + } |
|
97 | + |
|
98 | + public function childExists($name): bool { |
|
99 | + return false; |
|
100 | + } |
|
101 | + |
|
102 | + public function delete() { |
|
103 | + throw new Forbidden(); |
|
104 | + } |
|
105 | + |
|
106 | + public function getName(): string { |
|
107 | + return 'direct'; |
|
108 | + } |
|
109 | + |
|
110 | + public function setName($name) { |
|
111 | + throw new Forbidden(); |
|
112 | + } |
|
113 | + |
|
114 | + public function getLastModified(): int { |
|
115 | + return 0; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | } |
@@ -38,95 +38,95 @@ |
||
38 | 38 | |
39 | 39 | class ExecuteCommand extends Command implements CompletionAwareInterface { |
40 | 40 | |
41 | - /** @var IDBConnection */ |
|
42 | - private $connection; |
|
43 | - |
|
44 | - /** @var IConfig */ |
|
45 | - private $config; |
|
46 | - |
|
47 | - /** @var IAppManager */ |
|
48 | - protected $appManager; |
|
49 | - |
|
50 | - /** |
|
51 | - * ExecuteCommand constructor. |
|
52 | - * |
|
53 | - * @param IDBConnection $connection |
|
54 | - * @param IConfig $config |
|
55 | - * @param IAppManager $appManager |
|
56 | - */ |
|
57 | - public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) { |
|
58 | - $this->connection = $connection; |
|
59 | - $this->config = $config; |
|
60 | - |
|
61 | - parent::__construct(); |
|
62 | - } |
|
63 | - |
|
64 | - protected function configure() { |
|
65 | - $this |
|
66 | - ->setName('migrations:execute') |
|
67 | - ->setDescription('Execute a single migration version manually.') |
|
68 | - ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
69 | - ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
70 | - |
|
71 | - parent::configure(); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param InputInterface $input |
|
76 | - * @param OutputInterface $output |
|
77 | - * @return int |
|
78 | - */ |
|
79 | - public function execute(InputInterface $input, OutputInterface $output) { |
|
80 | - $appName = $input->getArgument('app'); |
|
81 | - $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
82 | - $version = $input->getArgument('version'); |
|
83 | - |
|
84 | - if ($this->config->getSystemValue('debug', false) === false) { |
|
85 | - $olderVersions = $ms->getMigratedVersions(); |
|
86 | - $olderVersions[] = '0'; |
|
87 | - $olderVersions[] = 'prev'; |
|
88 | - if (in_array($version, $olderVersions, true)) { |
|
89 | - $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
90 | - return 1; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - $ms->executeStep($version); |
|
96 | - return 0; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param string $optionName |
|
101 | - * @param CompletionContext $context |
|
102 | - * @return string[] |
|
103 | - */ |
|
104 | - public function completeOptionValues($optionName, CompletionContext $context) { |
|
105 | - return []; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $argumentName |
|
110 | - * @param CompletionContext $context |
|
111 | - * @return string[] |
|
112 | - */ |
|
113 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
114 | - if ($argumentName === 'app') { |
|
115 | - $allApps = \OC_App::getAllApps(); |
|
116 | - return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
117 | - } |
|
118 | - |
|
119 | - if ($argumentName === 'version') { |
|
120 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
121 | - |
|
122 | - $ms = new MigrationService($appName, $this->connection); |
|
123 | - $migrations = $ms->getAvailableVersions(); |
|
124 | - |
|
125 | - array_unshift($migrations, 'next', 'latest'); |
|
126 | - return $migrations; |
|
127 | - } |
|
128 | - |
|
129 | - return []; |
|
130 | - } |
|
41 | + /** @var IDBConnection */ |
|
42 | + private $connection; |
|
43 | + |
|
44 | + /** @var IConfig */ |
|
45 | + private $config; |
|
46 | + |
|
47 | + /** @var IAppManager */ |
|
48 | + protected $appManager; |
|
49 | + |
|
50 | + /** |
|
51 | + * ExecuteCommand constructor. |
|
52 | + * |
|
53 | + * @param IDBConnection $connection |
|
54 | + * @param IConfig $config |
|
55 | + * @param IAppManager $appManager |
|
56 | + */ |
|
57 | + public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) { |
|
58 | + $this->connection = $connection; |
|
59 | + $this->config = $config; |
|
60 | + |
|
61 | + parent::__construct(); |
|
62 | + } |
|
63 | + |
|
64 | + protected function configure() { |
|
65 | + $this |
|
66 | + ->setName('migrations:execute') |
|
67 | + ->setDescription('Execute a single migration version manually.') |
|
68 | + ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on') |
|
69 | + ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null); |
|
70 | + |
|
71 | + parent::configure(); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param InputInterface $input |
|
76 | + * @param OutputInterface $output |
|
77 | + * @return int |
|
78 | + */ |
|
79 | + public function execute(InputInterface $input, OutputInterface $output) { |
|
80 | + $appName = $input->getArgument('app'); |
|
81 | + $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output)); |
|
82 | + $version = $input->getArgument('version'); |
|
83 | + |
|
84 | + if ($this->config->getSystemValue('debug', false) === false) { |
|
85 | + $olderVersions = $ms->getMigratedVersions(); |
|
86 | + $olderVersions[] = '0'; |
|
87 | + $olderVersions[] = 'prev'; |
|
88 | + if (in_array($version, $olderVersions, true)) { |
|
89 | + $output->writeln('<error>Can not go back to previous migration without debug enabled</error>'); |
|
90 | + return 1; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + $ms->executeStep($version); |
|
96 | + return 0; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param string $optionName |
|
101 | + * @param CompletionContext $context |
|
102 | + * @return string[] |
|
103 | + */ |
|
104 | + public function completeOptionValues($optionName, CompletionContext $context) { |
|
105 | + return []; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $argumentName |
|
110 | + * @param CompletionContext $context |
|
111 | + * @return string[] |
|
112 | + */ |
|
113 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
114 | + if ($argumentName === 'app') { |
|
115 | + $allApps = \OC_App::getAllApps(); |
|
116 | + return array_diff($allApps, \OC_App::getEnabledApps(true, true)); |
|
117 | + } |
|
118 | + |
|
119 | + if ($argumentName === 'version') { |
|
120 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
121 | + |
|
122 | + $ms = new MigrationService($appName, $this->connection); |
|
123 | + $migrations = $ms->getAvailableVersions(); |
|
124 | + |
|
125 | + array_unshift($migrations, 'next', 'latest'); |
|
126 | + return $migrations; |
|
127 | + } |
|
128 | + |
|
129 | + return []; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | } |
@@ -30,19 +30,19 @@ |
||
30 | 30 | |
31 | 31 | class AddPreviewBackgroundCleanupJob implements IRepairStep { |
32 | 32 | |
33 | - /** @var IJobList */ |
|
34 | - private $jobList; |
|
33 | + /** @var IJobList */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | - public function __construct(IJobList $jobList) { |
|
37 | - $this->jobList = $jobList; |
|
38 | - } |
|
36 | + public function __construct(IJobList $jobList) { |
|
37 | + $this->jobList = $jobList; |
|
38 | + } |
|
39 | 39 | |
40 | - public function getName(): string { |
|
41 | - return 'Add preview background cleanup job'; |
|
42 | - } |
|
40 | + public function getName(): string { |
|
41 | + return 'Add preview background cleanup job'; |
|
42 | + } |
|
43 | 43 | |
44 | - public function run(IOutput $output) { |
|
45 | - $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | - } |
|
44 | + public function run(IOutput $output) { |
|
45 | + $this->jobList->add(BackgroundCleanupJob::class); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |