Skip to content

Commit

Permalink
Allow to not update metadata db
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Nov 10, 2023
1 parent 5ed6a97 commit 91c71d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/peergos/EmbeddedIpfs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/peergos/Nabu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 91c71d1

Please sign in to comment.