From 14a18343486b36e09be43f6d5e7a23a975afb74f Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 11 Sep 2020 18:36:06 -0400 Subject: [PATCH] Check for existence of module patch asset directory before iterating it in `Patch::cleanAutosave()`. --- src/patch.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/patch.cpp b/src/patch.cpp index 198496bb..8df2a684 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -179,17 +179,19 @@ void PatchManager::saveAutosave() { void PatchManager::cleanAutosave() { // Remove files and folders in the `autosave/modules` folder that doesn't match a module in the rack. std::string modulesDir = system::join(asset::autosavePath, "modules"); - for (const std::string& entry : system::getEntries(modulesDir)) { - try { - int64_t moduleId = std::stol(system::getFilename(entry)); - // Ignore modules that exist in the rack - if (APP->engine->getModule(moduleId)) - continue; + if (system::isDirectory(modulesDir)) { + for (const std::string& entry : system::getEntries(modulesDir)) { + try { + int64_t moduleId = std::stol(system::getFilename(entry)); + // Ignore modules that exist in the rack + if (APP->engine->getModule(moduleId)) + continue; + } + catch (std::invalid_argument& e) { + } + // Remove the entry. + system::removeRecursively(entry); } - catch (std::invalid_argument& e) { - } - // Remove the entry. - system::removeRecursively(entry); } }