mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit c46f2f446bd94259f6e2098c24b8d5cd51e66d61
parent c7d57a9825f7463a953748038b963513605e4a53
Author: markseu <mark2011@mayberg.se>
Date:   Mon, 22 Aug 2016 11:54:13 +0200

System update (better update)

Diffstat:
Msystem/plugins/core.php | 25++++++++++---------------
Msystem/plugins/update.php | 28+++++++++++++++++++++-------
2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/system/plugins/core.php b/system/plugins/core.php @@ -2281,11 +2281,6 @@ class YellowLookup return $fileName; } - function findFileNew($fileName, $fileNew, $pathBase, $nameDefault) - { - return $this->findFileFromConfig($fileName, $fileNew, $nameDefault); //TODO: Remove later - } - // Return file path from title function findFileFromTitle($titlePrefix, $titleText, $fileName, $fileDefault, $fileExtension) { @@ -2819,13 +2814,6 @@ class YellowToolbox return $ok; } - // Set file modification date, Unix time - function modifyFile($fileName, $modified) - { - clearstatcache(true, $fileName); - return @touch($fileName, $modified); - } - // Copy file function copyFile($fileNameSource, $fileNameDest, $mkdir = false) { @@ -2896,10 +2884,11 @@ class YellowToolbox return $ok; } - // Return file extension - function getFileExtension($fileName) + // Set file modification date, Unix time + function modifyFile($fileName, $modified) { - return strtoloweru(($pos = strrposu($fileName, '.')) ? substru($fileName, $pos+1) : ""); + clearstatcache(true, $fileName); + return @touch($fileName, $modified); } // Return file modification date, Unix time @@ -2908,6 +2897,12 @@ class YellowToolbox return is_file($fileName) ? filemtime($fileName) : 0; } + // Return file extension + function getFileExtension($fileName) + { + return strtoloweru(($pos = strrposu($fileName, '.')) ? substru($fileName, $pos+1) : ""); + } + // Return lines from text string function getTextLines($text) { diff --git a/system/plugins/update.php b/system/plugins/update.php @@ -5,7 +5,7 @@ // Update plugin class YellowUpdate { - const VERSION = "0.6.9"; + const VERSION = "0.6.10"; var $yellow; //access to API // Handle initialisation @@ -75,11 +75,15 @@ class YellowUpdate // Update pending software function updateCommandPending($args) { - $statusCode = $this->update(); - if($statusCode!=0) + $statusCode = 0; + if($this->isSoftwarePending()) { - if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; - echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n"; + $statusCode = $this->update(); + if($statusCode!=0) + { + if($statusCode!=200) echo "ERROR updating files: ".$this->yellow->page->get("pageError")."\n"; + echo "Yellow has ".($statusCode!=200 ? "not " : "")."been updated: Please run command again\n"; + } } return $statusCode; } @@ -265,7 +269,7 @@ class YellowUpdate function processRequestPending($serverScheme, $serverName, $base, $location, $fileName) { $statusCode = 0; - if($this->isContentFile($fileName)) + if($this->isContentFile($fileName) && $this->isSoftwarePending()) { $statusCode = $this->update(); if($statusCode==200) @@ -282,7 +286,7 @@ class YellowUpdate function processRequestInstallation($serverScheme, $serverName, $base, $location, $fileName) { $statusCode = 0; - if($this->isContentFile($fileName)) + if($this->isContentFile($fileName) && $this->isInstallation()) { $this->yellow->pages->pages["root/"] = array(); $this->yellow->page = new YellowPage($this->yellow); @@ -516,6 +520,16 @@ class YellowUpdate return !is_null($data[$software]); } + // Check if pending software exists + function isSoftwarePending() + { + $path = $this->yellow->config->get("pluginDir"); + $foundPlugins = count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false))>0; + $path = $this->yellow->config->get("themeDir"); + $foundThemes = count($this->yellow->toolbox->getDirectoryEntries($path, "/^.*\.zip$/", true, false))>0; + return $foundPlugins || $foundThemes; + } + // Check if installation requested function isInstallation() {