From 5eb64025f92d9534609d82052e520c049ba0de62 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 20 Jun 2016 10:49:53 -0700 Subject: [PATCH 1/3] remove management directories in node --- src/node/platform.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/platform.cpp b/src/node/platform.cpp index 6d355cc2..6a0820c3 100644 --- a/src/node/platform.cpp +++ b/src/node/platform.cpp @@ -66,7 +66,12 @@ void remove_realm_files_from_directory(const std::string &dir_path) while (struct dirent *entry = readdir(dir)) { if (strstr(entry->d_name, ".realm")) { // Intentionally not complaining if there was an error. - unlink(entry->d_name); + if (entry->d_type == DT_DIR) { + rmdir(entry->d_name); + } + else { + unlink(entry->d_name); + } } } From 5488eff9b9e5acf744017c284b8168a9459f2ffb Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 20 Jun 2016 11:41:18 -0700 Subject: [PATCH 2/3] recursively delete management directories --- src/node/platform.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/node/platform.cpp b/src/node/platform.cpp index 6a0820c3..ae382c70 100644 --- a/src/node/platform.cpp +++ b/src/node/platform.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include @@ -58,24 +58,8 @@ void copy_bundled_realm_files() void remove_realm_files_from_directory(const std::string &dir_path) { - DIR *dir = opendir(dir_path.c_str()); - if (!dir) { - return; - } - - while (struct dirent *entry = readdir(dir)) { - if (strstr(entry->d_name, ".realm")) { - // Intentionally not complaining if there was an error. - if (entry->d_type == DT_DIR) { - rmdir(entry->d_name); - } - else { - unlink(entry->d_name); - } - } - } - - closedir(dir); + std::string delete_realms = "rm -rf " + dir_path + "/*.realm*"; + system(delete_realms.c_str()); } } // realm From 7d42d26fe9c59569e4ef37e91707cd6e7209f5a8 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Mon, 20 Jun 2016 12:02:55 -0700 Subject: [PATCH 3/3] quote dir path --- src/node/platform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/platform.cpp b/src/node/platform.cpp index ae382c70..3915e87e 100644 --- a/src/node/platform.cpp +++ b/src/node/platform.cpp @@ -58,7 +58,7 @@ void copy_bundled_realm_files() void remove_realm_files_from_directory(const std::string &dir_path) { - std::string delete_realms = "rm -rf " + dir_path + "/*.realm*"; + std::string delete_realms = "rm -rf '" + dir_path + "'/*.realm*"; system(delete_realms.c_str()); }