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...");
|
LOGGER.info("Preparing output path...");
|
||||||
String compressedOutputPath = String.format("%s%s", Settings.getInstance().getBootstrapFilenamePrefix(), this.getFilename());
|
Path compressedOutputPath = this.getBootstrapOutputPath();
|
||||||
try {
|
try {
|
||||||
Files.delete(Paths.get(compressedOutputPath));
|
Files.delete(compressedOutputPath);
|
||||||
} catch (NoSuchFileException e) {
|
} catch (NoSuchFileException e) {
|
||||||
// Doesn't exist, so no need to delete
|
// 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
|
// Return the path to the compressed bootstrap file
|
||||||
Path finalPath = Paths.get(compressedOutputPath);
|
LOGGER.info("Bootstrap creation complete. Output file: {}", compressedOutputPath.toAbsolutePath().toString());
|
||||||
return finalPath.toAbsolutePath().toString();
|
return compressedOutputPath.toAbsolutePath().toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TimeoutException e) {
|
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) {
|
private void updateStatus(String text) {
|
||||||
LOGGER.info(text);
|
LOGGER.info(text);
|
||||||
SplashFrame.getInstance().updateStatus(text);
|
SplashFrame.getInstance().updateStatus(text);
|
||||||
|
@ -68,7 +68,6 @@ public class BootstrapTests extends Common {
|
|||||||
@Test
|
@Test
|
||||||
public void testCreateAndImportBootstrap() throws DataException, InterruptedException, TransformationException, IOException {
|
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");
|
Path archivePath = Paths.get(Settings.getInstance().getRepositoryPath(), "archive", "2-900.dat");
|
||||||
BlockData block1000;
|
BlockData block1000;
|
||||||
byte[] originalArchiveContents;
|
byte[] originalArchiveContents;
|
||||||
@ -76,10 +75,13 @@ public class BootstrapTests extends Common {
|
|||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
this.buildDummyBlockchain(repository);
|
this.buildDummyBlockchain(repository);
|
||||||
|
|
||||||
|
Bootstrap bootstrap = new Bootstrap(repository);
|
||||||
|
Path bootstrapPath = bootstrap.getBootstrapOutputPath();
|
||||||
|
|
||||||
// Ensure the compressed bootstrap doesn't exist
|
// Ensure the compressed bootstrap doesn't exist
|
||||||
assertFalse(Files.exists(bootstrapPath));
|
assertFalse(Files.exists(bootstrapPath));
|
||||||
|
|
||||||
Bootstrap bootstrap = new Bootstrap(repository);
|
// Create bootstrap
|
||||||
bootstrap.create();
|
bootstrap.create();
|
||||||
|
|
||||||
// Ensure the compressed bootstrap exists
|
// Ensure the compressed bootstrap exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user