MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cli_uninstall_report_leftover_installer

Function cli_uninstall_report_leftover_installer

src/cli/cli.c:12830–12869  ·  view source on GitHub ↗

Report — never delete — the updater script sitting next to the binary. * * install.sh/install.ps1 copies itself beside the executable so `update` has * something to hand off to. Uninstall does NOT remove it, deliberately: we * cannot prove we own that file. The user may have put their own copy there, it * may be a symlink into a checkout, or a package manager may manage it. Deleting * a file

Source from the content-addressed store, hash-verified

12828 * shouldn't. Telling the user the exact path costs one line and leaves the
12829 * decision with them. */
12830static void cli_uninstall_report_leftover_installer(const char *bin_path, bool dry_run) {
12831 if (!bin_path || !bin_path[0]) {
12832 return;
12833 }
12834 const char *slash = strrchr(bin_path, '/');
12835#ifdef _WIN32
12836 const char *backslash = strrchr(bin_path, '\\');
12837 if (backslash && (!slash || backslash > slash)) {
12838 slash = backslash;
12839 }
12840 static const char *const installer_names[] = {"install.ps1", "install.sh"};
12841#else
12842 static const char *const installer_names[] = {"install.sh"};
12843#endif
12844 if (!slash || slash == bin_path) {
12845 return;
12846 }
12847 size_t dir_len = (size_t)(slash - bin_path);
12848 for (size_t i = 0; i < sizeof(installer_names) / sizeof(installer_names[0]); i++) {
12849 char installer_path[CLI_BUF_1K];
12850 int written = snprintf(installer_path, sizeof(installer_path), "%.*s/%s", (int)dir_len,
12851 bin_path, installer_names[i]);
12852 if (written <= 0 || (size_t)written >= sizeof(installer_path)) {
12853 continue;
12854 }
12855 struct stat installer_status;
12856 if (stat(installer_path, &installer_status) != 0) {
12857 continue;
12858 }
12859 if (dry_run) {
12860 printf("Would leave %s in place (remove it yourself if you want it gone).\n",
12861 installer_path);
12862 } else {
12863 printf("\nLeft in place: %s\n"
12864 " This is the updater; uninstall does not delete it because it cannot\n"
12865 " prove it owns it. To remove it as well:\n\n rm \"%s\"\n",
12866 installer_path, installer_path);
12867 }
12868 }
12869}
12870
12871/* Uninstall is an activation too: removing the executable or its indexes
12872 * while a daemon generation is starting/running would leave live sessions on

Callers 1

cli_uninstall_activateFunction · 0.85

Calls 1

statClass · 0.70

Tested by

no test coverage detected