Fix for update showing available when one isn't #707

This commit is contained in:
Nabeel Shahzad 2020-05-21 11:06:27 -04:00
parent 52379c3789
commit 975ee9b88e
4 changed files with 20 additions and 10 deletions

View File

@ -36,7 +36,7 @@ class MaintenanceController extends Controller
return view('admin.maintenance.index', [
'cron_path' => $this->cronSvc->getCronExecString(),
'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'),
]);
}

View File

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

View File

@ -131,7 +131,12 @@ class UpdateController extends Controller
public function update_download(Request $request)
{
$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');
return redirect('/update');

View File

@ -6,8 +6,13 @@
</h6>
<div class="row" style="padding-top: 5px">
<div class="col-sm-12">
<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">
@if ($new_version)
<p>An update to version {{ $new_version_tag }} is available.</p>
@ -18,12 +23,6 @@
<p>There is no new version available</p>
@endif
</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>