forked from Qortal/qortal
Rework of bootstrap finalization process.
This commit is contained in:
parent
47ce884bbe
commit
a1e4047695
@ -273,18 +273,20 @@ public class Bootstrap {
|
||||
);
|
||||
}
|
||||
|
||||
LOGGER.info("Compressing...");
|
||||
String compressedOutputPath = String.format("%s%s", Settings.getInstance().getBootstrapFilenamePrefix(), this.getFilename());
|
||||
LOGGER.info("Preparing output path...");
|
||||
Path compressedOutputPath = this.getBootstrapOutputPath();
|
||||
try {
|
||||
Files.delete(Paths.get(compressedOutputPath));
|
||||
Files.delete(compressedOutputPath);
|
||||
} catch (NoSuchFileException e) {
|
||||
// Doesn't exist, so no need to delete
|
||||
}
|
||||
SevenZ.compress(compressedOutputPath, outputPath.toFile());
|
||||
|
||||
LOGGER.info("Compressing...");
|
||||
SevenZ.compress(compressedOutputPath.toString(), outputPath.toFile());
|
||||
|
||||
// Return the path to the compressed bootstrap file
|
||||
Path finalPath = Paths.get(compressedOutputPath);
|
||||
return finalPath.toAbsolutePath().toString();
|
||||
LOGGER.info("Bootstrap creation complete. Output file: {}", compressedOutputPath.toAbsolutePath().toString());
|
||||
return compressedOutputPath.toAbsolutePath().toString();
|
||||
|
||||
}
|
||||
catch (TimeoutException e) {
|
||||
@ -493,6 +495,13 @@ public class Bootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
public Path getBootstrapOutputPath() {
|
||||
Path initialPath = Paths.get(Settings.getInstance().getRepositoryPath()).toAbsolutePath().getParent();
|
||||
String compressedFilename = String.format("%s%s", Settings.getInstance().getBootstrapFilenamePrefix(), this.getFilename());
|
||||
Path compressedOutputPath = Paths.get(initialPath.toString(), compressedFilename);
|
||||
return compressedOutputPath;
|
||||
}
|
||||
|
||||
private void updateStatus(String text) {
|
||||
LOGGER.info(text);
|
||||
SplashFrame.getInstance().updateStatus(text);
|
||||
|
@ -68,7 +68,6 @@ public class BootstrapTests extends Common {
|
||||
@Test
|
||||
public void testCreateAndImportBootstrap() throws DataException, InterruptedException, TransformationException, IOException {
|
||||
|
||||
Path bootstrapPath = Paths.get(String.format("%s%s", Settings.getInstance().getBootstrapFilenamePrefix(), "bootstrap-archive.7z"));
|
||||
Path archivePath = Paths.get(Settings.getInstance().getRepositoryPath(), "archive", "2-900.dat");
|
||||
BlockData block1000;
|
||||
byte[] originalArchiveContents;
|
||||
@ -76,10 +75,13 @@ public class BootstrapTests extends Common {
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
this.buildDummyBlockchain(repository);
|
||||
|
||||
Bootstrap bootstrap = new Bootstrap(repository);
|
||||
Path bootstrapPath = bootstrap.getBootstrapOutputPath();
|
||||
|
||||
// Ensure the compressed bootstrap doesn't exist
|
||||
assertFalse(Files.exists(bootstrapPath));
|
||||
|
||||
Bootstrap bootstrap = new Bootstrap(repository);
|
||||
// Create bootstrap
|
||||
bootstrap.create();
|
||||
|
||||
// Ensure the compressed bootstrap exists
|
||||
|
Loading…
x
Reference in New Issue
Block a user