mirror of https://github.com/aseprite/aseprite.git
Fix uninstalling (or updating) an extensions that has subdirectories results in an error (fix #3385)
Prior to this fix, any additional external files or directories within the Extension's directory tree, break the subdirectory removal iteration, resulting in empty subdirectories and a console error.
This commit is contained in:
parent
fecfbb1145
commit
877ae9eeec
|
|
@ -41,6 +41,8 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "base/log.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
namespace {
|
||||
|
|
@ -368,7 +370,6 @@ void Extension::uninstall(const DeletePluginPref delPref)
|
|||
|
||||
// Remove all files inside the extension path
|
||||
uninstallFiles(m_path, delPref);
|
||||
ASSERT(!base::is_directory(m_path) || delPref == DeletePluginPref::kNo);
|
||||
|
||||
m_isEnabled = false;
|
||||
m_isInstalled = false;
|
||||
|
|
@ -422,7 +423,13 @@ void Extension::uninstallFiles(const std::string& path,
|
|||
|
||||
for (const auto& dir : installedDirs) {
|
||||
TRACE("EXT: Deleting directory '%s'\n", dir.c_str());
|
||||
base::remove_directory(dir);
|
||||
try {
|
||||
base::remove_directory(dir);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
LOG(ERROR, "RECO: Extension subdirectory cannot be removed, it's not empty.\n"
|
||||
" Error: %s\n", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
// Delete __info.json file if it does exist (e.g. maybe the
|
||||
|
|
@ -435,8 +442,15 @@ void Extension::uninstallFiles(const std::string& path,
|
|||
}
|
||||
|
||||
TRACE("EXT: Deleting extension directory '%s'\n", path.c_str());
|
||||
if (!hasPrefFile)
|
||||
base::remove_directory(path);
|
||||
if (!hasPrefFile) {
|
||||
try {
|
||||
base::remove_directory(path);
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
LOG(ERROR, "RECO: Extension directory cannot be removed, it's not empty.\n"
|
||||
" Error: %s\n", ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
#else // The following code delete the whole "path",
|
||||
// we prefer the __info.json approach.
|
||||
|
|
|
|||
Loading…
Reference in New Issue