From a524d12e0cee57b7356a5f6642541b284b7edf53 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 22 Jun 2025 09:33:04 +1200 Subject: [PATCH] 'Generic Commit' --- getpkg/src/main.cpp | 24 +++++++++++++++--------- getpkg/test.sh | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/getpkg/src/main.cpp b/getpkg/src/main.cpp index 670bef4..1dd9ffe 100644 --- a/getpkg/src/main.cpp +++ b/getpkg/src/main.cpp @@ -325,12 +325,12 @@ int publish_tool(int argc, char* argv[]) { int update_tool(int argc, char* argv[]) { std::cout << "Updating getpkg itself..." << std::endl; - // First update getpkg itself + // First try to update getpkg itself char* fakeArgv[] = {argv[0], (char*)"install", (char*)"getpkg"}; int result = install_tool(3, fakeArgv); if (result != 0) { - std::cerr << "Failed to update getpkg" << std::endl; - return result; + std::cerr << "Warning: Failed to update getpkg (may not be published)" << std::endl; + // Continue with updating other tools instead of failing } // Then update all installed tools @@ -338,12 +338,18 @@ int update_tool(int argc, char* argv[]) { std::filesystem::path configDir = std::filesystem::path(home) / ".config/getpkg"; std::cout << "Updating all installed tools..." << std::endl; - for (const auto& entry : std::filesystem::directory_iterator(configDir)) { - if (entry.path().extension() == ".json") { - std::string tname = entry.path().stem(); - if (tname != "getpkg") { // Skip getpkg since we already updated it - char* toolArgv[] = {argv[0], (char*)"install", (char*)tname.c_str()}; - install_tool(3, toolArgv); + bool anyUpdates = false; + if (std::filesystem::exists(configDir)) { + for (const auto& entry : std::filesystem::directory_iterator(configDir)) { + if (entry.path().extension() == ".json") { + std::string tname = entry.path().stem(); + if (tname != "getpkg") { // Skip getpkg since we already tried it + std::cout << "Checking " << tname << "..." << std::endl; + char* toolArgv[] = {argv[0], (char*)"install", (char*)tname.c_str()}; + if (install_tool(3, toolArgv) == 0) { + anyUpdates = true; + } + } } } } diff --git a/getpkg/test.sh b/getpkg/test.sh index 1ad6b87..3fc9082 100755 --- a/getpkg/test.sh +++ b/getpkg/test.sh @@ -331,7 +331,7 @@ fi # Test 14: Update command (if we have tools installed) if [ -d ~/.config/getpkg ] && [ "$(find ~/.config/getpkg -name "*.json" -type f 2>/dev/null | wc -l)" -gt 0 ]; then echo -e "\nTest 14: Update command" - UPDATE_ALL_OUTPUT=$(timeout 3 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT="" + UPDATE_ALL_OUTPUT=$(timeout 30 "$GETPKG" update 2>&1) || UPDATE_ALL_OUTPUT="" if [[ "$UPDATE_ALL_OUTPUT" =~ Update\ complete ]]; then print_test_result "Update all tools command" 0 else