(Android) Directories for corrupt themes are now automatically removed when the theme downloader is started

This commit is contained in:
Leon Styhre 2024-11-24 17:32:22 +01:00
parent 6c6dc82ef6
commit f0ea55b9f2
2 changed files with 30 additions and 0 deletions

View file

@ -1100,6 +1100,9 @@ void GuiThemeDownloader::setupFullscreenViewer()
void GuiThemeDownloader::update(int deltaTime)
{
if (!mAttemptedFetch) {
#if defined(__ANDROID__)
removeDisabledRepositories();
#endif
// We need to run this here instead of from the constructor so that GuiMsgBox will be
// on top of the GUI stack if it needs to be displayed.
mAttemptedFetch = true;
@ -1375,6 +1378,32 @@ std::vector<HelpPrompt> GuiThemeDownloader::getHelpPrompts()
return prompts;
}
void GuiThemeDownloader::removeDisabledRepositories()
{
const Utils::FileSystem::StringList& dirContent {
Utils::FileSystem::getDirContent(mThemeDirectory)};
std::vector<std::string> disabledDirs;
for (auto& directory : dirContent) {
if (Utils::FileSystem::isRegularFile(directory))
continue;
if (Utils::FileSystem::getFileName(directory).length() > 9) {
if (directory.substr(directory.length() - 9, 9) == "_DISABLED")
disabledDirs.emplace_back(directory);
}
}
if (disabledDirs.empty())
return;
for (auto& directory : disabledDirs) {
LOG(LogInfo) << "GuiThemeDownloader: Removing disabled theme directory \"" << directory
<< "\"";
Utils::FileSystem::removeDirectory(directory, true);
}
}
bool GuiThemeDownloader::fetchThemesList()
{
const std::string repositoryName {"themes-list"};

View file

@ -90,6 +90,7 @@ private:
}
};
void removeDisabledRepositories();
bool fetchThemesList();
bool fetchRepository(const std::string& repositoryName, bool allowReset = false);
bool cloneRepository(const std::string& repositoryName, const std::string& url);