install&update add lock file

This commit is contained in:
xiaomlove
2022-04-17 16:59:59 +08:00
parent e0a515b66c
commit 425402b46b
3 changed files with 16 additions and 0 deletions
+12
View File
@@ -632,4 +632,16 @@ class Install
return compact('version', 'match');
}
public function checkLock($path)
{
if (file_exists("$path/.lock")) {
die("Locked! Delete .lock file first");
}
}
public function setLock($path)
{
file_put_contents("$path/.lock", "Lock at: " . date('Y-m-d H:i:s'));
}
}
+2
View File
@@ -5,6 +5,7 @@ require ROOT_PATH . 'nexus/Install/install_update_start.php';
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
$install = new \Nexus\Install\Install();
$install->checkLock(__DIR__);
$currentStep = $install->currentStep();
$maxStep = $install->maxStep();
if (!$install->canAccessStep($currentStep)) {
@@ -191,6 +192,7 @@ if (!empty($error) || (isset($mysqlInfo) && !$mysqlInfo['match'])) {
echo '<div class="mb-6">For questions, consult the installation log at: <code>' . $install->getLogFile() . '</code></div>';
echo '<div class="text-red-500">For security reasons, please delete the following directories</div>';
echo '<div class="text-red-500"><code>' . $install->getInsallDirectory() . '</code></div>';
$install->setLock(__DIR__);
}
echo'</div>';
+2
View File
@@ -5,6 +5,7 @@ require ROOT_PATH . 'nexus/Install/install_update_start.php';
$isPost = $_SERVER['REQUEST_METHOD'] == 'POST';
$update = new \Nexus\Install\Update();
$update->checkLock(__DIR__);
$currentStep = $update->currentStep();
$maxStep = $update->maxStep();
if (!$update->canAccessStep($currentStep)) {
@@ -227,6 +228,7 @@ if (!empty($error) || (isset($mysqlInfo) && !$mysqlInfo['match'])) {
echo '<div class="mb-6">For questions, consult the upgrade log at: <code>' . $update->getLogFile() . '</code></div>';
echo '<div class="text-red-500">For security reasons, please delete the following directories</div>';
echo '<div class="text-red-500"><code>' . $update->getUpdateDirectory() . '</code></div>';
$update->setLock(__DIR__);
}
echo'</div>';