]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove old version of temporary space setup check and fix tests
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 16 Jan 2024 12:50:44 +0000 (13:50 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 25 Jan 2024 10:47:29 +0000 (11:47 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
apps/settings/lib/Controller/CheckSetupController.php
apps/settings/tests/Controller/CheckSetupControllerTest.php
core/js/setupchecks.js
core/js/tests/specs/setupchecksSpec.js

index bc898060928b490c178a81e0702a373670fb6074..ba39579e44597fa81f753acdd09f610c1b78f59f 100644 (file)
@@ -202,42 +202,6 @@ Raw output
                return false;
        }
 
-       protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
-               $objectStore = $this->config->getSystemValue('objectstore', null);
-               $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
-
-               if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
-                       return true;
-               }
-
-               if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
-                       return true;
-               }
-
-               if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
-                       return true;
-               }
-
-               $tempPath = sys_get_temp_dir();
-               if (!is_dir($tempPath)) {
-                       $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. Returned value: ' . $tempPath);
-                       return false;
-               }
-               $freeSpaceInTemp = function_exists('disk_free_space') ? disk_free_space($tempPath) : false;
-               if ($freeSpaceInTemp === false) {
-                       $this->logger->error('Error while checking the available disk space of temporary PHP path or no free disk space returned. Temporary path: ' . $tempPath);
-                       return false;
-               }
-
-               $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
-               if ($freeSpaceInTempInGB > 50) {
-                       return true;
-               }
-
-               $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
-               return false;
-       }
-
        /**
         * @return DataResponse
         * @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\Overview)
@@ -247,7 +211,6 @@ Raw output
                        [
                                'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
                                'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
-                               'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
                                'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
                                'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(),
                                'generic' => $this->setupCheckManager->runAll(),
index b888e0ce7c80987eba9ccd9204f694ae598a4c8a..f8c9b346e7d1812bbea0d87a7158358de211d061 100644 (file)
@@ -118,7 +118,6 @@ class CheckSetupControllerTest extends TestCase {
                                'getCurlVersion',
                                'isPhpOutdated',
                                'isPHPMailerUsed',
-                               'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
                        ])->getMock();
        }
 
@@ -141,11 +140,6 @@ class CheckSetupControllerTest extends TestCase {
                $this->request->expects($this->never())
                        ->method('getHeader');
 
-               $this->checkSetupController
-                       ->expects($this->once())
-                       ->method('isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed')
-                       ->willReturn(true);
-
                $this->urlGenerator->method('linkToDocs')
                        ->willReturnCallback(function (string $key): string {
                                if ($key === 'admin-performance') {
@@ -180,7 +174,6 @@ class CheckSetupControllerTest extends TestCase {
                $expected = new DataResponse(
                        [
                                'reverseProxyDocs' => 'reverse-proxy-doc-link',
-                               'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,
                                'reverseProxyGeneratedURL' => 'https://server/index.php',
                                'isFairUseOfFreePushService' => false,
                                'temporaryDirectoryWritable' => false,
@@ -645,48 +638,4 @@ Array
                );
                $this->assertEquals($expected, $this->checkSetupController->getFailedIntegrityCheckFiles());
        }
-
-       public function dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed() {
-               return [
-                       ['singlebucket', 'OC\\Files\\ObjectStore\\Swift', true],
-                       ['multibucket', 'OC\\Files\\ObjectStore\\Swift', true],
-                       ['singlebucket', 'OC\\Files\\ObjectStore\\Custom', true],
-                       ['multibucket', 'OC\Files\\ObjectStore\\Custom', true],
-                       ['singlebucket', 'OC\Files\ObjectStore\Swift', true],
-                       ['multibucket', 'OC\Files\ObjectStore\Swift', true],
-                       ['singlebucket', 'OC\Files\ObjectStore\Custom', true],
-                       ['multibucket', 'OC\Files\ObjectStore\Custom', true],
-               ];
-       }
-
-       /**
-        * @dataProvider dataForIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed
-        */
-       public function testIsEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(string $mode, string $className, bool $expected) {
-               $this->config->method('getSystemValue')
-                       ->willReturnCallback(function ($key, $default) use ($mode, $className) {
-                               if ($key === 'objectstore' && $mode === 'singlebucket') {
-                                       return ['class' => $className];
-                               }
-                               if ($key === 'objectstore_multibucket' && $mode === 'multibucket') {
-                                       return ['class' => $className];
-                               }
-                               return $default;
-                       });
-
-               $checkSetupController = new CheckSetupController(
-                       'settings',
-                       $this->request,
-                       $this->config,
-                       $this->urlGenerator,
-                       $this->l10n,
-                       $this->checker,
-                       $this->logger,
-                       $this->tempManager,
-                       $this->notificationManager,
-                       $this->setupCheckManager,
-               );
-
-               $this->assertSame($expected, $this->invokePrivate($checkSetupController, 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed'));
-       }
 }
index 761fca14ed912cbcceeec6cec62e702e2bde7b59..7e068ffd1d032e6d4a921fde0c2a8a6cc11720c2 100644 (file)
                                                });
                                        }
 
-                                       if (!data.isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed) {
-                                               messages.push({
-                                                       msg: t('core', 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.'),
-                                                       type: OC.SetupChecks.MESSAGE_TYPE_WARNING
-                                               })
-                                       }
                                        if (!data.temporaryDirectoryWritable) {
                                                messages.push({
                                                        msg: t('core', 'The temporary directory of this instance points to an either non-existing or non-writable directory.'),
index ef5ed8fbf4d084cfec5e85e8281e6b5c59083876..6a4f68b977d62e0d739738615d6733deda2c4ef7 100644 (file)
@@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -260,7 +259,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -296,7 +294,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -333,7 +330,6 @@ describe('OC.SetupChecks tests', function() {
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
                                        reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -399,7 +395,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -444,7 +439,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
                                        reverseProxyGeneratedURL: 'http://server',
                                        temporaryDirectoryWritable: true,
@@ -479,7 +473,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
                                        reverseProxyGeneratedURL: 'http://server',
                                        temporaryDirectoryWritable: true,
@@ -501,40 +494,6 @@ describe('OC.SetupChecks tests', function() {
                        });
                });
 
-               it('should return an error if there is not enough free space in the temp directory', function(done) {
-                       var async = OC.SetupChecks.checkSetup();
-
-                       suite.server.requests[0].respond(
-                               200,
-                               {
-                                       'Content-Type': 'application/json',
-                               },
-                               JSON.stringify({
-                                       isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
-                                       reverseProxyGeneratedURL: 'https://server',
-                                       temporaryDirectoryWritable: true,
-                                       generic: {
-                                               network: {
-                                                       "Internet connectivity": {
-                                                               severity: "success",
-                                                               description: null,
-                                                               linkToDoc: null
-                                                       }
-                                               },
-                                       },
-                               })
-                       );
-
-                       async.done(function( data, s, x ){
-                               expect(data).toEqual([{
-                                       msg: 'This instance uses an S3 based object store as primary storage. The uploaded files are stored temporarily on the server and thus it is recommended to have 50 GB of free space available in the temp directory of PHP. Check the logs for full details about the path and the available space. To improve this please change the temporary directory in the php.ini or make more space available in that path.',
-                                       type: OC.SetupChecks.MESSAGE_TYPE_WARNING
-                               }]);
-                               done();
-                       });
-               });
-
                it('should return an info if there is no default phone region', function(done) {
                        var async = OC.SetupChecks.checkSetup();
 
@@ -545,7 +504,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: true,
                                        generic: {
@@ -586,7 +544,6 @@ describe('OC.SetupChecks tests', function() {
                                },
                                JSON.stringify({
                                        isFairUseOfFreePushService: true,
-                                       isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
                                        reverseProxyGeneratedURL: 'https://server',
                                        temporaryDirectoryWritable: false,
                                        generic: {