diff --git a/packages/encrypted-blockstore/src/loader.ts b/packages/encrypted-blockstore/src/loader.ts index 7387ecfb..83303941 100644 --- a/packages/encrypted-blockstore/src/loader.ts +++ b/packages/encrypted-blockstore/src/loader.ts @@ -331,7 +331,7 @@ export class Loader implements Loadable { let splitcount = Math.ceil(size / threshold) let splitpercount = Math.floor(count / splitcount) let newcount = 0 - let clonedt = new CarTransaction(t.parent) + let clonedt = new CarTransaction(t.parent, { add: false }) for (const { cid, bytes } of t.entries()) { newcount++ clonedt.putSync(cid, bytes) @@ -339,15 +339,15 @@ export class Loader implements Loadable { const carFile = theKey && this.ebOpts.crypto ? await encryptedEncodeCarFile( - this.ebOpts.crypto, - theKey, - roots[0], - clonedt - ) + this.ebOpts.crypto, + theKey, + roots[0], + clonedt + ) : await encodeCarFile([roots[0]], clonedt) carFiles.push(carFile) - clonedt = new CarTransaction(t.parent) - newcount=0 + clonedt = new CarTransaction(t.parent, { add: false }) + newcount = 0 } } return carFiles diff --git a/packages/encrypted-blockstore/src/transaction.ts b/packages/encrypted-blockstore/src/transaction.ts index 0e272647..4d412c13 100644 --- a/packages/encrypted-blockstore/src/transaction.ts +++ b/packages/encrypted-blockstore/src/transaction.ts @@ -23,9 +23,11 @@ export type TransactionMeta = TM export class CarTransaction extends MemoryBlockstore implements CarMakeable { parent: EncryptedBlockstore - constructor(parent: EncryptedBlockstore) { + constructor(parent: EncryptedBlockstore, opts = { add: true }) { super() - parent.transactions.add(this) + if (opts.add) { + parent.transactions.add(this) + } this.parent = parent }