From de1e199dff88826806fd4dd231e41ab317bf023d Mon Sep 17 00:00:00 2001 From: Netkas Date: Wed, 25 Oct 2023 14:00:24 -0400 Subject: [PATCH] Fixed issue where a newline is sometimes added to the end of a download output due to how short the download process was, mitigated the issue by enforcing a "done" update at the end of the download process A fix has been implemented for an issue where a newline was unintentionally added to the end of download output, mostly when the download process was too short. This has been mitigated by ensuring a "done" update whenever a download finishes. At the same time, improvements have been made to the download progress output. Specifically, the downloaded size now won't exceed the total download size, and a definitive "100%" progress indication is enforced when the download ends. --- CHANGELOG.md | 2 ++ src/ncc/Managers/PackageManager.php | 11 ++++++++++- src/ncc/Objects/PackageLock/PackageEntry.php | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69cd069..f940e65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ This update introduces minor bug fixes. - Fixed division by zero in ConsoleProgressBar - Fixed issue where progress bar is displayed in VERBOSE mode - Set default process timeouts to null + - Fixed issue where a newline is sometimes added to the end of a download output due to how short the download process + was, mitigated the issue by enforcing a "done" update at the end of the download process ## [2.0.3] - 2023-10-17 diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index 7ea7e5c..c4e3982 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -906,6 +906,11 @@ return; } + if($downloaded > $download_size) + { + $download_size = $downloaded; + } + if(Resolver::checkLogLevel(LogLevel::VERBOSE, Main::getLogLevel())) { $percentage = round(($downloaded / $download_size) * 100, 2); @@ -926,10 +931,14 @@ } }); - unset($progress_bar); curl_exec($curl); fclose($file_handle); + $progress_bar->setMaxValue(100); + $progress_bar->setValue(100); + $progress_bar->setMiscText('done', true); + unset($progress_bar); + if(curl_errno($curl)) { ShutdownHandler::declareTemporaryPath($file_path); diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index 5206743..c07dc1b 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -24,6 +24,7 @@ namespace ncc\Objects\PackageLock; + use Exception; use InvalidArgumentException; use ncc\Classes\PackageReader; use ncc\Enums\FileDescriptor; @@ -41,6 +42,7 @@ use ncc\Objects\ProjectConfiguration\UpdateSource; use ncc\ThirdParty\composer\Semver\Semver; use ncc\ThirdParty\jelix\Version\VersionComparator; + use ncc\Utilities\Console; use ncc\Utilities\Functions; use ncc\Utilities\IO; @@ -189,8 +191,9 @@ { $version = $this->getLatestVersion(); } - catch(InvalidArgumentException $e) + catch(Exception $e) { + Console::outWarning(sprintf('Unable to find latest version for package %s, called on versionExists() in PackageEntry: %s', $this->name, $e->getMessage())); return false; } }