Reoptimize the recycle cleaners

This commit is contained in:
ME1312 2023-12-24 19:07:01 -05:00
parent 903b8a98d3
commit d1cb53e0f5
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
2 changed files with 14 additions and 18 deletions

View File

@ -195,8 +195,8 @@ public final class SubProxy extends BungeeCommon implements Listener {
if (recycle.isDirectory()) {
int kept = 0;
for (File file : recycle.listFiles()) {
try {
if (file.isDirectory()) {
try {
if (new File(recycle, file.getName() + "/info.json").exists()) {
FileReader reader = new FileReader(new File(recycle, file.getName() + "/info.json"));
YAMLSection info = new YAMLSection(new Gson().fromJson(Util.readAll(reader), Map.class));
@ -208,16 +208,14 @@ public final class SubProxy extends BungeeCommon implements Listener {
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
Directories.delete(file);
} else {
Files.delete(file.toPath());
}
Logger.get("SubServers").info("Removed ./SubServers/Recently Deleted/" + file.getName());
} catch (Exception e) {
Logger.get("SubServers").warning("Problem scanning ./SubServers/Recently Deleted/" + file.getName());
e.printStackTrace();
Files.delete(file.toPath());
}
}
if (kept == 0) {
Files.delete(recycle.toPath());

View File

@ -136,8 +136,8 @@ public final class ExHost {
if (recycle.isDirectory()) {
int kept = 0;
for (File file : recycle.listFiles()) {
try {
if (file.isDirectory()) {
try {
if (new File(recycle, file.getName() + "/info.json").exists()) {
FileReader reader = new FileReader(new File(recycle, file.getName() + "/info.json"));
JSONObject info = new JSONObject(Util.readAll(reader));
@ -149,16 +149,14 @@ public final class ExHost {
}
}
}
} catch (Exception e) {
log.error.println(e);
}
Directories.delete(file);
} else {
Files.delete(file.toPath());
}
log.info.println("Removed ./SubServers/Recently Deleted/" + file.getName());
} catch (Exception e) {
log.error.println("Problem scanning ./SubServers/Recently Deleted/" + file.getName());
log.error.println(e);
Files.delete(file.toPath());
}
log.info.println("Removed ./Recently Deleted/" + file.getName());
}
if (kept == 0) {
Files.delete(recycle.toPath());