Fix cleanup

This commit is contained in:
Maurice Heumann 2023-02-23 19:23:24 +01:00
parent 4b0e45fb6a
commit 56d7869a21
2 changed files with 18 additions and 5 deletions

View File

@ -335,11 +335,11 @@ namespace updater
return; return;
} }
this->cleanup_root_directory(); this->cleanup_root_directory(files);
this->cleanup_data_directory(files); this->cleanup_data_directory(files);
} }
void file_updater::cleanup_root_directory() const void file_updater::cleanup_root_directory(const std::vector<file_info>& files) const
{ {
const auto existing_files = utils::io::list_files(this->base_); const auto existing_files = utils::io::list_files(this->base_);
for (const auto& file : existing_files) for (const auto& file : existing_files)
@ -350,8 +350,21 @@ namespace updater
continue; continue;
} }
std::error_code code{}; bool found = false;
std::filesystem::remove_all(file, code); for (const auto& wantedFile : files)
{
if (wantedFile.name == entry)
{
found = true;
break;
}
}
if (!found)
{
std::error_code code{};
std::filesystem::remove_all(file, code);
}
} }
} }

View File

@ -34,7 +34,7 @@ namespace updater
void delete_old_process_file() const; void delete_old_process_file() const;
void cleanup_directories(const std::vector<file_info>& files) const; void cleanup_directories(const std::vector<file_info>& files) const;
void cleanup_root_directory() const; void cleanup_root_directory(const std::vector<file_info>& files) const;
void cleanup_data_directory(const std::vector<file_info>& files) const; void cleanup_data_directory(const std::vector<file_info>& files) const;
}; };
} }