Fixing error during upload
This commit is contained in:
parent
041bb9fd55
commit
4891ce0f9f
3 changed files with 24 additions and 16 deletions
|
@ -2,24 +2,33 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Web\Session;
|
||||
use Monolog\Logger;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use RuntimeException;
|
||||
use ZipArchive;
|
||||
use function glob_recursive;
|
||||
use function redirect;
|
||||
use function removeDirectory;
|
||||
use function route;
|
||||
use function urlFor;
|
||||
|
||||
class UpgradeController extends Controller
|
||||
{
|
||||
const GITHUB_SOURCE_API = 'https://api.github.com/repos/SergiX44/XBackBone/releases';
|
||||
|
||||
/**
|
||||
* @param Response $response
|
||||
* @param Response $response
|
||||
*
|
||||
* @param Logger $logger
|
||||
* @param Session $session
|
||||
* @return Response
|
||||
*/
|
||||
public function upgrade(Response $response): Response
|
||||
public function upgrade(Response $response, Logger $logger, Session $session): Response
|
||||
{
|
||||
if (!is_writable(BASE_DIR)) {
|
||||
$this->session->alert(lang('path_not_writable', BASE_DIR), 'warning');
|
||||
$session->alert(lang('path_not_writable', BASE_DIR), 'warning');
|
||||
|
||||
return redirect($response, route('system'));
|
||||
}
|
||||
|
@ -27,13 +36,13 @@ class UpgradeController extends Controller
|
|||
try {
|
||||
$json = $this->getApiJson();
|
||||
} catch (RuntimeException $e) {
|
||||
$this->session->alert($e->getMessage(), 'danger');
|
||||
$session->alert($e->getMessage(), 'danger');
|
||||
|
||||
return redirect($response, route('system'));
|
||||
}
|
||||
|
||||
if (version_compare($json[0]->tag_name, PLATFORM_VERSION, '<=')) {
|
||||
$this->session->alert(lang('already_latest_version'), 'warning');
|
||||
$session->alert(lang('already_latest_version'), 'warning');
|
||||
|
||||
return redirect($response, route('system'));
|
||||
}
|
||||
|
@ -41,17 +50,17 @@ class UpgradeController extends Controller
|
|||
$tmpFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.'xbackbone_update.zip';
|
||||
|
||||
if (file_put_contents($tmpFile, file_get_contents($json[0]->assets[0]->browser_download_url)) === false) {
|
||||
$this->session->alert(lang('cannot_retrieve_file'), 'danger');
|
||||
$session->alert(lang('cannot_retrieve_file'), 'danger');
|
||||
|
||||
return redirect($response, route('system'));
|
||||
}
|
||||
|
||||
if (filesize($tmpFile) !== $json[0]->assets[0]->size) {
|
||||
$this->session->alert(lang('file_size_no_match'), 'danger');
|
||||
$session->alert(lang('file_size_no_match'), 'danger');
|
||||
|
||||
return redirect($response, route('system'));
|
||||
}
|
||||
$this->logger->info('System update started.');
|
||||
$logger->info('System update started.');
|
||||
|
||||
$config = require BASE_DIR.'config.php';
|
||||
$config['maintenance'] = true;
|
||||
|
@ -90,7 +99,7 @@ class UpgradeController extends Controller
|
|||
$updateZip->close();
|
||||
unlink($tmpFile);
|
||||
|
||||
$this->logger->info('System update completed.');
|
||||
$logger->info('System update completed.');
|
||||
|
||||
return redirect($response, urlFor('/install'));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
use App\Database\DB;
|
||||
use App\Web\Lang;
|
||||
use App\Web\Session;
|
||||
use Aws\S3\S3Client;
|
||||
use function DI\factory;
|
||||
use function DI\get;
|
||||
|
|
12
composer.lock
generated
12
composer.lock
generated
|
@ -4,20 +4,20 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "979e04cb72a48a50d7872132f8efa29f",
|
||||
"content-hash": "6a0e292aa56135b799030a6b1e2152c0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.134.3",
|
||||
"version": "3.134.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "3de2711a47e7c3f5e93a5c83f019188fd23f852f"
|
||||
"reference": "f5a2d82660e73ed613643a5e7ad833d2569d5fdf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3de2711a47e7c3f5e93a5c83f019188fd23f852f",
|
||||
"reference": "3de2711a47e7c3f5e93a5c83f019188fd23f852f",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f5a2d82660e73ed613643a5e7ad833d2569d5fdf",
|
||||
"reference": "f5a2d82660e73ed613643a5e7ad833d2569d5fdf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -88,7 +88,7 @@
|
|||
"s3",
|
||||
"sdk"
|
||||
],
|
||||
"time": "2020-04-03T18:11:51+00:00"
|
||||
"time": "2020-04-07T18:11:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "firebase/php-jwt",
|
||||
|
|
Loading…
Reference in a new issue