parent
55fe34095d
commit
d57617656f
|
|
@ -50,29 +50,32 @@ class ConfigFileManager {
|
|||
}
|
||||
}
|
||||
|
||||
static void deleteFolderIfExists(Path target) throws IOException {
|
||||
if (!Files.exists(target)) return;
|
||||
Files.walkFileTree(target, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
|
||||
throws IOException {
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException e)
|
||||
throws IOException {
|
||||
if (e == null) {
|
||||
Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void moveFolderIfExists(Path source, Path target) throws IOException {
|
||||
if (!Files.exists(source)) return;
|
||||
if (Files.exists(target)) {
|
||||
Files.walkFileTree(target, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
|
||||
throws IOException {
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException e)
|
||||
throws IOException {
|
||||
if (e == null) {
|
||||
Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
deleteFolderIfExists(target);
|
||||
Files.move(source, target);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -736,6 +736,13 @@ public class ConfigManager {
|
|||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
try {
|
||||
for (var user : UserService.getUsers()) {
|
||||
removeModulePrefs(user.id, packageName);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "remove module prefs for " + packageName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -749,7 +756,13 @@ public class ConfigManager {
|
|||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
}
|
||||
return true;
|
||||
try {
|
||||
removeModulePrefs(module.userId, module.packageName);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, "removeModulePrefs", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean disableModule(String packageName) {
|
||||
|
|
@ -924,6 +937,12 @@ public class ConfigManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void removeModulePrefs(int uid, String packageName) throws IOException {
|
||||
if (packageName == null) return;
|
||||
var path = Paths.get(getPrefsPath(packageName, uid));
|
||||
ConfigFileManager.deleteFolderIfExists(path);
|
||||
}
|
||||
|
||||
public String getManagerPackageName() {
|
||||
return manager;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue