Skip to content

Commit

Permalink
Rename canInstallExists method and add new method for removal
Browse files Browse the repository at this point in the history
Rename canInstallExists to shouldRemoveCanInstallFile to cover removal of this file for non-git channels and logging any failure to remove it.

Add new method to detect if this file exists during web based installation.

Signed-off-by: Alex Harpin <development@landsofshadow.co.uk>
  • Loading branch information
alexharpin committed Jun 19, 2021
1 parent 0466c80 commit 5c3a37d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/Command/Maintenance/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->printErrors($output, $errors);
return 1;
}
if ($setupHelper->canInstallExists()) {
if ($setupHelper->shouldRemoveCanInstallFile()) {
$output->writeln('<warn>Could not remove CAN_INSTALL from the config folder. Please remove this file manually.</warn>');
}
$output->writeln("Nextcloud was successfully installed");
Expand Down
4 changes: 2 additions & 2 deletions core/Controller/SetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function run($post) {
$post['dbpass'] = $post['dbpassword'];
}

if (!$this->setupHelper->canInstallExists()) {
if (!$this->setupHelper->canInstallFileExists()) {
$this->displaySetupForbidden();
return;
}
Expand Down Expand Up @@ -112,7 +112,7 @@ private function finishSetup(bool $installRecommended) {
}
\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();

if ($this->setupHelper->canInstallExists()) {
if ($this->setupHelper->shouldRemoveCanInstallFile()) {
\OC_Template::printGuestPage('', 'installation_incomplete');
}

Expand Down
11 changes: 9 additions & 2 deletions lib/private/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public function install($options) {

//and we are done
$config->setSystemValue('installed', true);
if (self::canInstallExists()) {
if (self::shouldRemoveCanInstallFile()) {
unlink(\OC::$configDir.'/CAN_INSTALL');
}

Expand Down Expand Up @@ -612,7 +612,14 @@ private function getVendor() {
/**
* @return bool
*/
public function canInstallExists() {
public function shouldRemoveCanInstallFile() {
return \OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL');
}

/**
* @return bool
*/
public function canInstallFileExists() {
return is_file(\OC::$configDir.'/CAN_INSTALL');
}
}

0 comments on commit 5c3a37d

Please sign in to comment.