Merge branch 'gateway-api-update' into develop

This commit is contained in:
Aleksey Bobkov 2019-01-10 17:52:10 -08:00
commit 3b41f82521
3 changed files with 29 additions and 11 deletions

View File

@ -227,10 +227,16 @@ class UpdateManager
$frozen = $installed->lists('is_frozen', 'code');
$updatable = $installed->lists('is_updatable', 'code');
$build = Parameter::get('system::core.build');
$themes = [];
if ($this->themeManager) {
$themes = array_keys($this->themeManager->getInstalled());
}
$params = [
'core' => $this->getHash(),
'plugins' => serialize($versions),
'themes' => serialize($themes),
'build' => $build,
'force' => $force
];
@ -557,12 +563,16 @@ class UpdateManager
* Downloads a plugin from the update server.
* @param string $name Plugin name.
* @param string $hash Expected file hash.
* @param boolean $installation Indicates whether this is a plugin installation request.
* @return self
*/
public function downloadPlugin($name, $hash)
public function downloadPlugin($name, $hash, $installation = false)
{
$fileCode = $name . $hash;
$this->requestServerFile('plugin/get', $fileCode, $hash, ['name' => $name]);
$this->requestServerFile('plugin/get', $fileCode, $hash, [
'name' => $name,
'installation' => $installation ? 1 : 0
]);
}
/**
@ -909,7 +919,14 @@ class UpdateManager
*/
protected function applyHttpAttributes($http, $postData)
{
$postData['server'] = base64_encode(serialize(['php' => PHP_VERSION, 'url' => Url::to('/')]));
$postData['protocol_version'] = '1.1';
$postData['client'] = 'october';
$postData['server'] = base64_encode(serialize([
'php' => PHP_VERSION,
'url' => Url::to('/'),
'since' => PluginVersion::orderBy('created_at')->value('created_at')
]));
if ($projectId = Parameter::get('system::project.id')) {
$postData['project'] = $projectId;

View File

@ -43,7 +43,7 @@ class PluginInstall extends Command
$hash = array_get($pluginDetails, 'hash');
$this->output->writeln(sprintf('<info>Downloading plugin: %s</info>', $code));
$manager->downloadPlugin($code, $hash);
$manager->downloadPlugin($code, $hash, true);
$this->output->writeln(sprintf('<info>Unpacking plugin: %s</info>', $code));
$manager->extractPlugin($code, $hash);

View File

@ -279,7 +279,7 @@ class Updates extends Controller
break;
case 'downloadPlugin':
$manager->downloadPlugin(post('name'), post('hash'));
$manager->downloadPlugin(post('name'), post('hash'), post('install'));
break;
case 'downloadTheme':
@ -439,7 +439,7 @@ class Updates extends Controller
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes);
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false);
/*
* Finish up
@ -534,7 +534,7 @@ class Updates extends Controller
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes);
$updateSteps = $this->buildUpdateSteps($core, $plugins, $themes, false);
/*
* Finish up
@ -553,7 +553,7 @@ class Updates extends Controller
return $this->makePartial('execute');
}
protected function buildUpdateSteps($core, $plugins, $themes)
protected function buildUpdateSteps($core, $plugins, $themes, $isInstallationRequest)
{
if (!is_array($core)) {
$core = [null, null];
@ -595,7 +595,8 @@ class Updates extends Controller
'code' => 'downloadPlugin',
'label' => Lang::get('system::lang.updates.plugin_downloading', compact('name')),
'name' => $name,
'hash' => $hash
'hash' => $hash,
'install' => $isInstallationRequest ? 1 : 0
];
}
@ -717,7 +718,7 @@ class Updates extends Controller
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps(null, $plugins, []);
$updateSteps = $this->buildUpdateSteps(null, $plugins, [], true);
/*
* Finish up
@ -845,7 +846,7 @@ class Updates extends Controller
/*
* Update steps
*/
$updateSteps = $this->buildUpdateSteps(null, $plugins, $themes);
$updateSteps = $this->buildUpdateSteps(null, $plugins, $themes, true);
/*
* Finish up