From 0135f25b9dd920165b849565360bd8e7c1c4f3c7 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Mon, 4 Oct 2021 09:15:54 +0100 Subject: [PATCH] Delete existing repository before extracting bootstrap This limits the amount of additional space needed to the size of the compressed bootstrap (currently just under 4GB for full nodes, or 200MB for top-only nodes). --- src/main/java/org/qortal/repository/Bootstrap.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/qortal/repository/Bootstrap.java b/src/main/java/org/qortal/repository/Bootstrap.java index cb6961e2..e72d253e 100644 --- a/src/main/java/org/qortal/repository/Bootstrap.java +++ b/src/main/java/org/qortal/repository/Bootstrap.java @@ -385,11 +385,6 @@ public class Bootstrap { blockchainLock.lockInterruptibly(); try { - this.updateStatus("Extracting bootstrap..."); - Path input = path.toAbsolutePath(); - Path output = path.toAbsolutePath().getParent().toAbsolutePath(); - SevenZ.decompress(input.toString(), output.toFile()); - this.updateStatus("Stopping repository..."); // Close the repository while we are still able to // Otherwise, the caller will run into difficulties when it tries to close it @@ -398,15 +393,22 @@ public class Bootstrap { // Now close the repository factory so that we can swap out the database files RepositoryManager.closeRepositoryFactory(); + this.updateStatus("Deleting existing repository..."); + Path input = path.toAbsolutePath(); + Path output = path.toAbsolutePath().getParent().toAbsolutePath(); Path inputPath = Paths.get(output.toString(), "bootstrap"); Path outputPath = Paths.get(Settings.getInstance().getRepositoryPath()); + FileUtils.deleteDirectory(outputPath.toFile()); + + this.updateStatus("Extracting bootstrap..."); + SevenZ.decompress(input.toString(), output.toFile()); + if (!inputPath.toFile().exists()) { throw new DataException("Extracted bootstrap doesn't exist"); } // Move the "bootstrap" folder in place of the "db" folder this.updateStatus("Moving files to output directory..."); - FileUtils.deleteDirectory(outputPath.toFile()); Files.move(inputPath, outputPath); this.updateStatus("Starting repository from bootstrap...");