forked from Qortal/qortal
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).
This commit is contained in:
parent
de3ebf664f
commit
0135f25b9d
@ -385,11 +385,6 @@ public class Bootstrap {
|
|||||||
blockchainLock.lockInterruptibly();
|
blockchainLock.lockInterruptibly();
|
||||||
|
|
||||||
try {
|
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...");
|
this.updateStatus("Stopping repository...");
|
||||||
// Close the repository while we are still able to
|
// Close the repository while we are still able to
|
||||||
// Otherwise, the caller will run into difficulties when it tries to close it
|
// 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
|
// Now close the repository factory so that we can swap out the database files
|
||||||
RepositoryManager.closeRepositoryFactory();
|
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 inputPath = Paths.get(output.toString(), "bootstrap");
|
||||||
Path outputPath = Paths.get(Settings.getInstance().getRepositoryPath());
|
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()) {
|
if (!inputPath.toFile().exists()) {
|
||||||
throw new DataException("Extracted bootstrap doesn't exist");
|
throw new DataException("Extracted bootstrap doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the "bootstrap" folder in place of the "db" folder
|
// Move the "bootstrap" folder in place of the "db" folder
|
||||||
this.updateStatus("Moving files to output directory...");
|
this.updateStatus("Moving files to output directory...");
|
||||||
FileUtils.deleteDirectory(outputPath.toFile());
|
|
||||||
Files.move(inputPath, outputPath);
|
Files.move(inputPath, outputPath);
|
||||||
|
|
||||||
this.updateStatus("Starting repository from bootstrap...");
|
this.updateStatus("Starting repository from bootstrap...");
|
||||||
|
Loading…
Reference in New Issue
Block a user