Merge pull request #710 from nabeelio/707-Update-Error

Auto-Update fixes #707
This commit is contained in:
Nabeel S 2020-05-21 12:28:52 -04:00 committed by GitHub
commit 1ebb181c36
4 changed files with 20 additions and 10 deletions

View File

@ -36,7 +36,7 @@ class MaintenanceController extends Controller
return view('admin.maintenance.index', [ return view('admin.maintenance.index', [
'cron_path' => $this->cronSvc->getCronExecString(), 'cron_path' => $this->cronSvc->getCronExecString(),
'cron_problem_exists' => $this->cronSvc->cronProblemExists(), 'cron_problem_exists' => $this->cronSvc->cronProblemExists(),
'new_version' => true, //$this->kvpRepo->get('new_version_available', false), 'new_version' => $this->kvpRepo->get('new_version_available', false),
'new_version_tag' => $this->kvpRepo->get('latest_version_tag'), 'new_version_tag' => $this->kvpRepo->get('latest_version_tag'),
]); ]);
} }

View File

@ -93,15 +93,18 @@ class VersionService extends Service
} }
$include_prerelease = setting('general.check_prerelease_version', false); $include_prerelease = setting('general.check_prerelease_version', false);
Log::info('Include prerelease='.$include_prerelease);
foreach ($releases as $release) { foreach ($releases as $release) {
if ($release['prerelease'] === true) { if ($release['prerelease'] === true) {
if ($include_prerelease) { if ($include_prerelease) {
Log::info('Found latest pre-release of '.$release['tag_name']); Log::info('Found latest pre-release of '.$release['tag_name']);
return $this->setLatestRelease( return $this->setLatestRelease(
$release['tag_name'], $release['tag_name'],
$this->getGithubAsset($release) $this->getGithubAsset($release)
); );
} }
continue; continue;
} }
@ -206,15 +209,18 @@ class VersionService extends Service
$current_version = $this->cleanVersionString($current_version); $current_version = $this->cleanVersionString($current_version);
} }
// Replace "dev" with "alpha", since
$latest_version = $this->getLatestVersion(); $latest_version = $this->getLatestVersion();
Log::info('Current version='.$current_version.'; latest detected='.$latest_version);
// No new/released version found
if (empty($latest_version)) { if (empty($latest_version)) {
$this->kvpRepo->save('new_version_available', false);
return false; return false;
} }
// Convert to semver // Convert to semver
if ($this->isGreaterThan($latest_version, $current_version)) { if ($this->isGreaterThan($latest_version, $current_version)) {
Log::info('Latest version "'.$latest_version.'" is greater than "'.$current_version.'"');
$this->kvpRepo->save('new_version_available', true); $this->kvpRepo->save('new_version_available', true);
return true; return true;
} }

View File

@ -131,7 +131,12 @@ class UpdateController extends Controller
public function update_download(Request $request) public function update_download(Request $request)
{ {
$version = $this->kvpRepo->get('latest_version_tag'); $version = $this->kvpRepo->get('latest_version_tag');
$this->updateManager->source('github')->update($version); if (empty($version)) {
return view('updater::steps/step1-no-update');
}
$release = $this->updateManager->source('github')->fetch($version);
$this->updateManager->source('github')->update($release);
Log::info('Update completed to '.$version.', redirecting'); Log::info('Update completed to '.$version.', redirecting');
return redirect('/update'); return redirect('/update');

View File

@ -6,8 +6,13 @@
</h6> </h6>
<div class="row" style="padding-top: 5px"> <div class="row" style="padding-top: 5px">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="row"> <div class="row">
<div class="col-sm-6">
<p>Force new version check</p>
{{ Form::open(['route' => 'admin.maintenance.forcecheck']) }}
{{ Form::button('Force update check', ['type' => 'submit', 'class' => 'btn btn-success']) }}
{{ Form::close() }}
</div>
<div class="col-sm-6"> <div class="col-sm-6">
@if ($new_version) @if ($new_version)
<p>An update to version {{ $new_version_tag }} is available.</p> <p>An update to version {{ $new_version_tag }} is available.</p>
@ -18,12 +23,6 @@
<p>There is no new version available</p> <p>There is no new version available</p>
@endif @endif
</div> </div>
<div class="col-sm-6">
<p>Force new version check</p>
{{ Form::open(['route' => 'admin.maintenance.forcecheck']) }}
{{ Form::button('Force update check', ['type' => 'submit', 'class' => 'btn btn-success']) }}
{{ Form::close() }}
</div>
</div> </div>
</div> </div>
</div> </div>