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/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..5998449 100644 --- a/lib/Migration/Version00001Date20201016095257.php +++ b/lib/Migration/Version00001Date20201016095257.php @@ -59,7 +59,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt ]); $table->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..2f54a5a 100644 --- a/tests/Controller/ChecksumAPIControllerTest.php +++ b/tests/Controller/ChecksumAPIControllerTest.php @@ -8,7 +8,7 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\Files\NotFoundException; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use OCP\IRequest; use OCP\IUser; use OCP\IUserManager; @@ -45,7 +45,7 @@ protected function setUp() :void { $this->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); @@ -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); } @@ -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); }