From 8e6227963bb6d27311d931995c5269dfc1b3f40a Mon Sep 17 00:00:00 2001 From: ndnhat Date: Fri, 3 Feb 2023 17:30:14 +0700 Subject: [PATCH 1/2] =?UTF-8?q?-=20Update=20source=20code=20to=20suport=20?= =?UTF-8?q?Nextcloud=20v.25=20(Issue=20#8=20(B).1.4=20[=E6=A9=9F=E9=96=A2?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=AC=E3=83=BC=E3=82=B8]=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appinfo/app.php | 2 +- appinfo/database.xml | 50 ------------------- appinfo/info.xml | 2 +- lib/AppInfo/Application.php | 12 ++--- lib/Controller/ChecksumAPIController.php | 8 ++- lib/Hooks/UserHooks.php | 2 +- .../Version00001Date20201016095257.php | 4 +- .../Controller/ChecksumAPIControllerTest.php | 2 +- 8 files changed, 14 insertions(+), 68 deletions(-) delete mode 100644 appinfo/database.xml diff --git a/appinfo/app.php b/appinfo/app.php index d44b2b6..05b80ff 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -4,5 +4,5 @@ use OCA\ChecksumAPI\AppInfo\Application; -$app = \OC::$server->query(Application::class); +$app = \OC::$server->get(Application::class); $app->register(); \ No newline at end of file diff --git a/appinfo/database.xml b/appinfo/database.xml deleted file mode 100644 index 5c0942b..0000000 --- a/appinfo/database.xml +++ /dev/null @@ -1,50 +0,0 @@ - - *dbname* - true - false - utf8 - - *dbprefix*checksum_api - - - id - integer - true - true - true - true - 8 - - - fileid - integer - true - 0 - true - 8 - - - revision - integer - true - 0 - true - 8 - - - type - text - true - - 30 - - - hash - text - true - - 64 - - -
-
diff --git a/appinfo/info.xml b/appinfo/info.xml index aded7ab..75a15be 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -16,6 +16,6 @@ tools https://github.com/RCOSDP/nextcloud-checksum_api/issues - + diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index f538d47..038ad8a 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -17,13 +17,11 @@ public function __construct(array $urlParams = []) { /** * Controllers */ - $container->registerService('UserHooks', function() { - $container = $this->getContainer(); - $server = $container->getServer(); + $container->registerService('UserHooks', function($c) { return new UserHooks( - $server->getLogger(), - $server->getRootFolder(), - $server->getDatabaseConnection() + $c->get('ServerContainer')->getLogger(), + $c->get('ServerContainer')->getRootFolder(), + $c->get('ServerContainer')->getDatabaseConnection(), ); }); } @@ -34,6 +32,6 @@ public function register() { public function registerHooks() { $container = $this->getContainer(); - $container->query('UserHooks')->register(); + $container->get('UserHooks')->register(); } } \ No newline at end of file diff --git a/lib/Controller/ChecksumAPIController.php b/lib/Controller/ChecksumAPIController.php index 67e6558..88bcd55 100644 --- a/lib/Controller/ChecksumAPIController.php +++ b/lib/Controller/ChecksumAPIController.php @@ -4,14 +4,12 @@ namespace OCA\ChecksumAPI\Controller; -use OC\Files\Filesystem; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; -use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use OCP\IRequest; use OCP\IUserSession; @@ -32,7 +30,7 @@ public function __construct($appName, IRootFolder $rootFolder, IUserSession $userSession, HashMapper $mapper, - ILogger $logger) { + LoggerInterface $logger) { parent::__construct($appName, $request); $this->rootFolder = $rootFolder; $this->userSession = $userSession; @@ -140,7 +138,7 @@ public function checksum($hash, $path, $revision) { $this->logger->info('latest version matches'); } else { // check if version function is enabled - if (!\OCP\App::isEnabled($this->versionAppId)) { + if (!\OC_App::isEnabled($this->versionAppId)) { $this->logger->error('version function is not enabled'); return new DataResponse( 'version function is not enabled', diff --git a/lib/Hooks/UserHooks.php b/lib/Hooks/UserHooks.php index 9c6644c..0fffdb0 100644 --- a/lib/Hooks/UserHooks.php +++ b/lib/Hooks/UserHooks.php @@ -7,9 +7,9 @@ use OCP\Files\IRootFolder; use OCP\IDBConnection; use OCP\ILogger; -use OC\Files\Filesystem; use OC\Files\Node\Node; +use OC\Files\View; use OCA\ChecksumAPI\Db\HashMapper; class UserHooks { diff --git a/lib/Migration/Version00001Date20201016095257.php b/lib/Migration/Version00001Date20201016095257.php index d0a7dd8..02521f3 100644 --- a/lib/Migration/Version00001Date20201016095257.php +++ b/lib/Migration/Version00001Date20201016095257.php @@ -1,4 +1,4 @@ -addColumn('hash', 'string', [ 'notnull' => true, - 'length' => 64, + 'length' => 128, 'default' => '', ]); $table->setPrimaryKey(['id']); diff --git a/tests/Controller/ChecksumAPIControllerTest.php b/tests/Controller/ChecksumAPIControllerTest.php index 3651760..510dbb8 100644 --- a/tests/Controller/ChecksumAPIControllerTest.php +++ b/tests/Controller/ChecksumAPIControllerTest.php @@ -168,7 +168,7 @@ public function testChecksumVersionAppIsDisabled() :void { $this->logger ); - $status = \OCP\App::isEnabled($this->versionAppId); + $status = \OC_App::isEnabled($this->versionAppId); if ($status) { \OC::$server->getAppManager()->disableApp($this->versionAppId); } From 90ddca05b0f353a8c98e840dac4a1613b11f0f0f Mon Sep 17 00:00:00 2001 From: ndnhat Date: Tue, 28 Feb 2023 10:12:32 +0700 Subject: [PATCH 2/2] =?UTF-8?q?refs=20(B)1.5=20[=E6=A9=9F=E9=96=A2?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=AC=E3=83=BC=E3=82=B8]=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C:=20Update=20Travis=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 ++-- lib/Migration/Version00001Date20201016095257.php | 2 +- tests/Controller/ChecksumAPIControllerTest.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index f6ae2db..68fd7bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: php php: - - '7.4' + - '8.1' env: global: @@ -19,7 +19,7 @@ before_script: - git clone https://github.com/nextcloud/server.git - mv server/ nextcloud - cd nextcloud - - git checkout origin/stable19 -b stable19 + - git checkout origin/stable25 -b stable25 - mkdir custom_apps - cp -pi ${TRAVIS_BUILD_DIR}/travis/apps.config.php config - cd 3rdparty diff --git a/lib/Migration/Version00001Date20201016095257.php b/lib/Migration/Version00001Date20201016095257.php index 02521f3..5998449 100644 --- a/lib/Migration/Version00001Date20201016095257.php +++ b/lib/Migration/Version00001Date20201016095257.php @@ -1,4 +1,4 @@ -mapper = $this->getMockBuilder(HashMapper::class)->disableOriginalConstructor()->getMock(); - $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); $this->file = $this->getMockBuilder('OCP\Files\File')->disableOriginalConstructor()->getMock(); $this->file->method('getId')->willReturn(1); @@ -201,7 +201,7 @@ public function testChecksumMatchesNoVersion() :void { $this->logger ); - $status = \OCP\App::isEnabled($this->versionAppId); + $status = \OC::$server->getAppManager()->isEnabledForUser($this->versionAppId); if (!$status) { \OC::$server->getAppManager()->disableApp($this->versionAppId); } @@ -246,7 +246,7 @@ public function testChecksumSucceedWithoutRevision() :void { $this->logger ); - $status = \OCP\App::isEnabled($this->versionAppId); + $status = \OC::$server->getAppManager()->isEnabledForUser($this->versionAppId); if (!$status) { \OC::$server->getAppManager()->disableApp($this->versionAppId); }