Skip to content

Commit

Permalink
changes to loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruv Soni authored and Dhruv Soni committed Jun 11, 2024
1 parent b3a17f4 commit 8be83a0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/encrypted-blockstore/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ export class Loader implements Loadable {
for (const car of cars) {
const { cid, bytes } = car
await this.carStore!.save({ cid, bytes })
await this.cacheTransaction(t)
const newDbMeta = { cars: [cid], key: this.key || null } as DbMeta
await this.remoteWAL!.enqueue(newDbMeta, opts)
await this.metaStore!.save(newDbMeta)
await this.updateCarLog([cid], fp, !!opts.compact)
cids.push(cid)
}

await this.cacheTransaction(t)
const newDbMeta = { cars: cids, key: this.key || null } as DbMeta
await this.remoteWAL!.enqueue(newDbMeta, opts)
await this.metaStore!.save(newDbMeta)
await this.updateCarLog(cids, fp, !!opts.compact)
return cids
}

Expand Down Expand Up @@ -335,7 +335,7 @@ export class Loader implements Loadable {
for (const { cid, bytes } of t.entries()) {
newcount++
clonedt.putSync(cid, bytes)
if (newcount > splitpercount) {
if (newcount >= splitpercount) {
const carFile =
theKey && this.ebOpts.crypto
? await encryptedEncodeCarFile(
Expand All @@ -347,6 +347,7 @@ export class Loader implements Loadable {
: await encodeCarFile([roots[0]], clonedt)
carFiles.push(carFile)
clonedt = new CarTransaction(t.parent)
newcount=0
}
}
return carFiles
Expand Down

0 comments on commit 8be83a0

Please sign in to comment.