Fix race condition when returning from an install
Fix checkbox wasn't disappearing from prev apps when installing a single app
pull/11/head
Squidly271 2021-10-30 22:46:03 -04:00
parent 9554ff42d5
commit cbf1156a68
5 changed files with 23 additions and 11 deletions

View File

@ -17,6 +17,11 @@ $plugin = "community.applications";
require_once "$docroot/plugins/$plugin/include/paths.php";
require_once "$docroot/plugins/$plugin/include/helpers.php";
require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$DockerClient = new DockerClient();
$DockerTemplates = new DockerTemplates();
// Restart logging over at start of every session
exec("rm -rf {$caPaths['CA_logs']}");
@ -94,6 +99,13 @@ if ( $cfg['updateCheck'] == "yes" ) {
exec("echo '/usr/local/emhttp/plugins/community.applications/scripts/checkForUpdates.php >/dev/null 2>&1' | at now >/dev/null");
}
}
if ( is_file("/var/run/dockerd.pid") && is_dir("/proc/".@file_get_contents("/var/run/dockerd.pid")) ) {
$caSettings['dockerRunning'] = true;
} else {
$caSettings['dockerSearch'] = "no";
unset($caSettings['dockerRunning']);
}
getAllInfo(true);
function tr($string,$ret=false) {
$string = str_replace('"',""",str_replace("'","'",_($string)));

View File

@ -1,8 +1,8 @@
8a8925a330db9068f1edeaff637b8d9b ./Apps.page
794c98df447faf75dd36d405b9675ac5 ./Apps.page
83b3f89cd42e8601c7c217d5b4889c81 ./CA_notices.page
7ee0b23dbd92ed55f611360a983f9565 ./ca_settings.page
1b49ec9797713ce869ea0c1066a109f2 ./default.cfg
b07cd3f62c0daad5a62cbb75847819c6 ./include/exec.php
41067a7aecc80c2885f4b6d8287d1077 ./include/exec.php
aee2d4e715238cef7938587ec497ad20 ./include/helpers.php
aeec70878e94eead3aef390110e786e8 ./include/paths.php
eb76c1b6ed3da5e5b393f22d2ec18430 ./javascript/libraries.js
@ -22,4 +22,4 @@ b398273cf7daa62ab00d2de2336ca25f ./README.md
2bd671daecaf01549f8cc0202cb184b3 ./scripts/updatePluginSupport.php
62fa68c6f6a42cdb79dd0d60b5f8a3f6 ./skins/Narrow/css.php
4ff34c148d3dde1a420303faecd414ae ./skins/Narrow/skin.html
fd5492300079650cac45773b5b8ba15d ./skins/Narrow/skin.php
109a70f36a452479a0cb4bfb905ab2dc ./skins/Narrow/skin.php

View File

@ -362,7 +362,6 @@ function getConvertedTemplates() {
$templates = readJsonFile($caPaths['community-templates-info']);
if ( empty($templates) ) return false;
exec("logger getConvertedTemplates");
foreach ($templates as $template) {
if ( ! $template['Private'] )
@ -1614,7 +1613,6 @@ function get_categories() {
}
}
}
getAllInfo(true);
postReturn(["categories"=>$cat]);
}

View File

@ -36,6 +36,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
$caSettings['dockerRunning'] = "true";
// $info = $DockerTemplates->getAllInfo();
$info = getAllInfo();
file_put_contents("/tmp/blah",print_r($info,true));
//$dockerRunning = $DockerClient->getDockerContainers();
$dockerUpdateStatus = readJsonFile($caPaths['dockerUpdateStatus']);
} else {
@ -103,7 +104,9 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
if ( ! $template['Plugin'] ) {
if ( $caSettings['dockerRunning'] ) {
foreach ($info as $testDocker) {
if ( ($template['Repository'] == $testDocker['Image'] || "{$template['Repository']}:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
$tmpRepo = strpos($template['Repository'],":") ? $template['Repository'] : $template['Repository'].":latest";
$tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
if ( ($tmpRepo == $testDocker['Image'] || "{$tmpRepo}:latest" == $testDocker['Image']) && ($template['Name'] == $testDocker['Name']) ) {
$selected = true;
$name = $testDocker['Name'];
break;
@ -115,8 +118,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
if ( $info[$ind]['url'] && $info[$ind]['running'] ) {
$actionsContext[] = array("icon"=>"ca_fa-globe","text"=>"WebUI","action"=>"openNewWindow('{$info[$ind]['url']}','_blank');");
}
$tmpRepo = strpos($template['Repository'],":") ? $template['Repository'] : $template['Repository'].":latest";
$tmpRepo = strpos($tmpRepo,"/") ? $tmpRepo : "library/$tmpRepo";
if ( ! filter_var($dockerUpdateStatus[$tmpRepo]['status'],FILTER_VALIDATE_BOOLEAN) ) {
$actionsContext[] = array("icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"updateDocker('$name');");
}
@ -194,6 +196,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
$actionsContext[] = array("icon"=>"ca_fa-install","text"=>tr("Install"),"action"=>"installLanguage('{$template['TemplateURL']}','$countryCode');");
}
if ( file_exists("/var/log/plugins/lang-$countryCode.xml") ) {
$template['Installed'] = true;
if ( languageCheck($template) ) {
$actionsContext[] = array("icon"=>"ca_fa-update","text"=>$template['UpdateLanguage'],"action"=>"updateLanguage('$countryCode');");
}
@ -767,7 +770,6 @@ function getRepoDescriptionSkin($repository) {
###########################
function displayCard($template) {
global $caSettings;
$appName = str_replace("-"," ",$template['display_dockerName']);
$popupType = $template['RepositoryTemplate'] ? "ca_repoPopup" : "ca_appPopup";
@ -887,7 +889,7 @@ function displayCard($template) {
} else
$card .= "<span class='favCardBackground' title='".htmlentities($favText)."' style='display:none;' data-repository='".htmlentities($RepoName,ENT_QUOTES)."'></span>";
if ($Removable && !$DockerInfo) {
if ($Removable && !$DockerInfo && ! $Installed) {
$previousAppName = $Plugin ? $PluginURL : $Name;
$type = ($appType == "appDocker") ? "docker" : "plugin";
$card .= "<input class='ca_multiselect ca_tooltip' title='".tr("Check off to select multiple reinstalls")."' type='checkbox' data-name='$previousAppName' data-humanName='$Name' data-type='$type' data-deletepath='$InstallPath' $checked>";
@ -939,7 +941,7 @@ function displayCard($template) {
}
}
$card .= "</div>";
if ( $Installed ) {
if ( $Installed || $Uninstall) {
$card .= "<div class='installedCardBackground'>";
$card .= "<div class='installedCardText ca_center'>".tr("INSTALLED")."</div>";
$card .= "</div>";