From 4d6c173c58a06b30d8a7f75edd6e244f4c9880d5 Mon Sep 17 00:00:00 2001 From: Cvolton Date: Tue, 14 Jan 2025 20:56:13 +0100 Subject: [PATCH] add stale index files cleanup --- loader/src/loader/LoaderImpl.cpp | 11 +++++++++++ loader/src/loader/LoaderImpl.hpp | 1 + 2 files changed, 12 insertions(+) diff --git a/loader/src/loader/LoaderImpl.cpp b/loader/src/loader/LoaderImpl.cpp index 209d32b17..93a405180 100644 --- a/loader/src/loader/LoaderImpl.cpp +++ b/loader/src/loader/LoaderImpl.cpp @@ -74,6 +74,16 @@ void Loader::Impl::createDirectories() { } } +void Loader::Impl::removeDirectories() { + // clean up of stale data from Geode v2 + if(std::filesystem::exists(dirs::getGeodeDir() / "index")) { + std::thread([] { + std::error_code ec; + std::filesystem::remove_all(dirs::getGeodeDir() / "index", ec); + }).detach(); + } +} + Result<> Loader::Impl::setup() { if (m_isSetup) { return Ok(); @@ -105,6 +115,7 @@ Result<> Loader::Impl::setup() { { log::NestScope nest; this->createDirectories(); + this->removeDirectories(); this->addSearchPaths(); } diff --git a/loader/src/loader/LoaderImpl.hpp b/loader/src/loader/LoaderImpl.hpp index 928dd7ca0..0895f6cc7 100644 --- a/loader/src/loader/LoaderImpl.hpp +++ b/loader/src/loader/LoaderImpl.hpp @@ -79,6 +79,7 @@ namespace geode { ~Impl(); void createDirectories(); + void removeDirectories(); void updateModResources(Mod* mod); void addSearchPaths();