Added check of cases like #191
This commit is contained in:
parent
8fd6a1cb19
commit
8fbaded18d
3 changed files with 19 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sergix44/xbackbone",
|
||||
"version": "3.1.1",
|
||||
"version": "3.1.2",
|
||||
"description": "A lightweight ShareX PHP backend",
|
||||
"type": "project",
|
||||
"require": {
|
||||
|
|
|
@ -102,11 +102,10 @@ $app->get('/', function (Response $response, View $view, Session $session) {
|
|||
})->setName('install');
|
||||
|
||||
$app->post('/', function (Request $request, Response $response, Filesystem $storage, Session $session, DB $db) use (&$config) {
|
||||
// Check if there is a previous installation, if not, setup the config file
|
||||
$installed = true;
|
||||
|
||||
// disable debug in production
|
||||
unset($config['debug']);
|
||||
|
||||
// Check if there is a previous installation, if not, setup the config file
|
||||
if (!file_exists(__DIR__.'/../config.php')) {
|
||||
$installed = false;
|
||||
|
||||
|
@ -154,6 +153,21 @@ $app->post('/', function (Request $request, Response $response, Filesystem $stor
|
|||
$config['storage']['path'] = param($request, 'storage_path');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$installed = true;
|
||||
if (isset($config['storage_dir'])) { // if from older installations with no support of other than local driver
|
||||
$config['storage']['driver'] = 'local';
|
||||
$config['storage']['path'] = $config['storage_dir'];
|
||||
unset($config['storage_dir']);
|
||||
}
|
||||
|
||||
if ($config['storage']['driver'] === 'local' && !is_dir($config['storage']['path'])) { // if installed with local driver, and the storage dir don't exists
|
||||
$realPath = realpath(BASE_DIR.$config['storage']['path']);
|
||||
if (is_dir($realPath) && is_writable($realPath)) { // and was a path relative to the upper folder
|
||||
$config['storage']['path'] = $realPath; // update the config
|
||||
$storage->getAdapter()->setPathPrefix($realPath); // update the prefix
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if the storage is valid
|
||||
|
@ -176,14 +190,6 @@ $app->post('/', function (Request $request, Response $response, Filesystem $stor
|
|||
return redirect($response, urlFor('/install'));
|
||||
}
|
||||
|
||||
// if from older installations with no support of other than local driver
|
||||
// update the config
|
||||
if ($installed && isset($config['storage_dir'])) {
|
||||
$config['storage']['driver'] = 'local';
|
||||
$config['storage']['path'] = $config['storage_dir'];
|
||||
unset($config['storage_dir']);
|
||||
}
|
||||
|
||||
// Build the dns string and run the migrations
|
||||
try {
|
||||
$migrator = new Migrator($db, __DIR__.'/../resources/schemas');
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
<div class="form-group row">
|
||||
<div class="col-sm-12 d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-lg btn-outline-primary">
|
||||
<i class="fas fa-sync fa-fw"></i> Update database
|
||||
<i class="fas fa-sync fa-fw"></i> Finalize update
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue