mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Properly delete old update files
This commit is contained in:
@@ -63,6 +63,7 @@ namespace hex::paths {
|
||||
|
||||
const static inline impl::ConfigPath Config("config");
|
||||
const static inline impl::ConfigPath Recent("recent");
|
||||
const static inline impl::ConfigPath Updates("updates");
|
||||
|
||||
const static inline impl::PluginPath Libraries("lib");
|
||||
const static inline impl::PluginPath Plugins("plugins");
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace hex::init {
|
||||
if (files.size() <= count)
|
||||
return;
|
||||
|
||||
std::sort(files.begin(), files.end(), [](const auto& a, const auto& b) {
|
||||
std::ranges::sort(files, [](const auto& a, const auto& b) {
|
||||
return std::filesystem::last_write_time(a) > std::filesystem::last_write_time(b);
|
||||
});
|
||||
|
||||
@@ -226,6 +226,13 @@ namespace hex::init {
|
||||
keepNewest(10, paths::Logs);
|
||||
keepNewest(25, paths::Backups);
|
||||
|
||||
// Remove all old update files
|
||||
for (const auto &path : paths::Updates.all()) {
|
||||
for (const auto &entry : std::filesystem::directory_iterator(path)) {
|
||||
wolv::io::fs::removeAll(entry.path());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ std::optional<std::fs::path> downloadUpdate(const std::string &url) {
|
||||
{
|
||||
// Loop over all available paths
|
||||
wolv::io::File file;
|
||||
for (const auto &path : hex::paths::Config.write()) {
|
||||
for (const auto &path : hex::paths::Updates.write()) {
|
||||
// Remove any existing update files
|
||||
wolv::io::fs::remove(path / updateFileName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user