From 98831a9449b76fc36c6f8cc16746085299f08004 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 5 Feb 2022 17:53:49 +0000 Subject: [PATCH] Break out of the various loops in the cleanup manager if the thread is stopping. --- .../ArbitraryDataCleanupManager.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataCleanupManager.java b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataCleanupManager.java index e1eaa491..64916df5 100644 --- a/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataCleanupManager.java +++ b/src/main/java/org/qortal/controller/arbitrary/ArbitraryDataCleanupManager.java @@ -239,6 +239,9 @@ public class ArbitraryDataCleanupManager extends Thread { // Delete random data associated with name if we're over our storage limit for this name // Use the DELETION_THRESHOLD, for the same reasons as above for (String followedName : storageManager.followedNames()) { + if (isStopping) { + return; + } if (!storageManager.isStorageSpaceAvailableForName(repository, followedName, DELETION_THRESHOLD)) { this.storageLimitReachedForName(repository, followedName); } @@ -261,6 +264,9 @@ public class ArbitraryDataCleanupManager extends Thread { // Loop through each path and find those without matching signatures for (Path path : allPaths) { + if (isStopping) { + break; + } try { String[] contents = path.toFile().list(); if (contents == null || contents.length == 0) { @@ -287,6 +293,9 @@ public class ArbitraryDataCleanupManager extends Thread { private void checkForExpiredTransactions(Repository repository) { List expiredPaths = this.findPathsWithNoAssociatedTransaction(repository); for (Path expiredPath : expiredPaths) { + if (isStopping) { + return; + } LOGGER.info("Found path with no associated transaction: {}", expiredPath.toString()); this.safeDeleteDirectory(expiredPath.toFile(), "no matching transaction"); } @@ -308,6 +317,9 @@ public class ArbitraryDataCleanupManager extends Thread { // when they reach their storage limit Path dataPath = Paths.get(Settings.getInstance().getDataPath()); for (int i=0; i