diff --git a/src/client/updater/file_updater.cpp b/src/client/updater/file_updater.cpp index 508cda49..fedc43ad 100644 --- a/src/client/updater/file_updater.cpp +++ b/src/client/updater/file_updater.cpp @@ -335,11 +335,11 @@ namespace updater return; } - this->cleanup_root_directory(); + this->cleanup_root_directory(files); this->cleanup_data_directory(files); } - void file_updater::cleanup_root_directory() const + void file_updater::cleanup_root_directory(const std::vector& files) const { const auto existing_files = utils::io::list_files(this->base_); for (const auto& file : existing_files) @@ -350,8 +350,21 @@ namespace updater continue; } - std::error_code code{}; - std::filesystem::remove_all(file, code); + bool found = false; + for (const auto& wantedFile : files) + { + if (wantedFile.name == entry) + { + found = true; + break; + } + } + + if (!found) + { + std::error_code code{}; + std::filesystem::remove_all(file, code); + } } } diff --git a/src/client/updater/file_updater.hpp b/src/client/updater/file_updater.hpp index 626ef134..b5e09c40 100644 --- a/src/client/updater/file_updater.hpp +++ b/src/client/updater/file_updater.hpp @@ -34,7 +34,7 @@ namespace updater void delete_old_process_file() const; void cleanup_directories(const std::vector& files) const; - void cleanup_root_directory() const; + void cleanup_root_directory(const std::vector& files) const; void cleanup_data_directory(const std::vector& files) const; }; }