'Generic Commit'
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 45s
Build-Test-Publish / build (linux/arm64) (push) Successful in 55s

This commit is contained in:
Your Name 2025-06-22 12:27:45 +12:00
parent cd07649040
commit b9a7cc718d

View File

@ -626,8 +626,9 @@ int clean_tool(int argc, char* argv[]) {
} }
} }
// Step 3: Clean up ~/.local/bin/getpkg/ - remove dangling symlinks // Step 3: Clean up ~/.local/bin/getpkg/ - remove dangling symlinks and non-symlinks
int danglingSymlinksRemoved = 0; int danglingSymlinksRemoved = 0;
int nonSymlinksRemoved = 0;
if (std::filesystem::exists(binDir)) { if (std::filesystem::exists(binDir)) {
for (const auto& entry : std::filesystem::directory_iterator(binDir)) { for (const auto& entry : std::filesystem::directory_iterator(binDir)) {
if (entry.is_symlink()) { if (entry.is_symlink()) {
@ -644,6 +645,15 @@ int clean_tool(int argc, char* argv[]) {
std::filesystem::remove(entry.path()); std::filesystem::remove(entry.path());
danglingSymlinksRemoved++; danglingSymlinksRemoved++;
} }
} else {
// Remove anything that's not a symlink (directories, regular files, etc.)
std::cout << "Removing non-symlink: " << entry.path().filename() << std::endl;
if (entry.is_directory()) {
std::filesystem::remove_all(entry.path());
} else {
std::filesystem::remove(entry.path());
}
nonSymlinksRemoved++;
} }
} }
} }
@ -722,6 +732,7 @@ int clean_tool(int argc, char* argv[]) {
std::cout << "\nCleanup complete:" << std::endl; std::cout << "\nCleanup complete:" << std::endl;
std::cout << " - Removed " << configFilesRemoved << " orphaned config files" << std::endl; std::cout << " - Removed " << configFilesRemoved << " orphaned config files" << std::endl;
std::cout << " - Removed " << danglingSymlinksRemoved << " dangling symlinks" << std::endl; std::cout << " - Removed " << danglingSymlinksRemoved << " dangling symlinks" << std::endl;
std::cout << " - Removed " << nonSymlinksRemoved << " non-symlinks from ~/.local/bin/getpkg" << std::endl;
std::cout << " - Cleaned " << autocompleteCleaned << " autocomplete entries" << std::endl; std::cout << " - Cleaned " << autocompleteCleaned << " autocomplete entries" << std::endl;
std::cout << " - Removed " << emptyDirsRemoved << " empty directories" << std::endl; std::cout << " - Removed " << emptyDirsRemoved << " empty directories" << std::endl;