From 91c71d1518ee8a280a0695c1e1471d1f7a8811e9 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 10 Nov 2023 12:25:24 +0000 Subject: [PATCH] Allow to not update metadata db --- src/main/java/org/peergos/EmbeddedIpfs.java | 8 +++++--- src/main/java/org/peergos/Nabu.java | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/peergos/EmbeddedIpfs.java b/src/main/java/org/peergos/EmbeddedIpfs.java index 6931450e..e0cb0541 100644 --- a/src/main/java/org/peergos/EmbeddedIpfs.java +++ b/src/main/java/org/peergos/EmbeddedIpfs.java @@ -143,15 +143,17 @@ public static BlockMetadataStore buildBlockMetadata(Args a) { throw new RuntimeException(e); } } - public static Blockstore buildBlockStore(Config config, Path ipfsPath, BlockMetadataStore meta) { + public static Blockstore buildBlockStore(Config config, Path ipfsPath, BlockMetadataStore meta, boolean updateMetadb) { Blockstore withMetadb; if (config.datastore.blockMount.prefix.equals("flatfs.datastore")) { CachingBlockMetadataStore cachedBlocks = new CachingBlockMetadataStore(new FileBlockstore(ipfsPath), meta); - cachedBlocks.updateMetadataStoreIfEmpty(); + if (updateMetadb) + cachedBlocks.updateMetadataStoreIfEmpty(); withMetadb = cachedBlocks; } else if (config.datastore.blockMount.prefix.equals("s3.datastore")) { S3Blockstore s3blocks = new S3Blockstore(config.datastore.blockMount.getParams(), meta); - s3blocks.updateMetadataStoreIfEmpty(); + if (updateMetadb) + s3blocks.updateMetadataStoreIfEmpty(); withMetadb = s3blocks; } else { throw new IllegalStateException("Unrecognized datastore prefix: " + config.datastore.blockMount.prefix); diff --git a/src/main/java/org/peergos/Nabu.java b/src/main/java/org/peergos/Nabu.java index 34df3e5f..acbf69cc 100644 --- a/src/main/java/org/peergos/Nabu.java +++ b/src/main/java/org/peergos/Nabu.java @@ -53,7 +53,7 @@ public Nabu(Args args) throws Exception { DatabaseRecordStore records = new DatabaseRecordStore(datastorePath.toAbsolutePath().toString()); BlockMetadataStore meta = buildBlockMetadata(args); EmbeddedIpfs ipfs = EmbeddedIpfs.build(records, - buildBlockStore(config, ipfsPath, meta), + buildBlockStore(config, ipfsPath, meta, true), true, config.addresses.getSwarmAddresses(), config.bootstrap.getBootstrapAddresses(),