Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions packages/hub/src/utils/createXorbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export async function* createXorbs(
let xorbId = 0;

await chunkModule.init();
const chunker = new chunkModule.Chunker(TARGET_CHUNK_SIZE);
const chunkCache = new ChunkCache();
let xorb = new CurrentXorbInfo();

Expand Down Expand Up @@ -147,8 +146,9 @@ export async function* createXorbs(

const remoteXorbHashes: string[] = [""]; // starts at index 1 (to simplify implem a bit)

try {
for await (const fileSource of fileSources) {
for await (const fileSource of fileSources) {
const chunker = new chunkModule.Chunker(TARGET_CHUNK_SIZE);
try {
xorb.fileSize[fileSource.path] = fileSource.content.size;

// Load dedup info for the first chunk of the file, if it's potentially modified by the splice
Expand Down Expand Up @@ -342,22 +342,22 @@ export async function* createXorbs(
dedupRatio,
representation: fileRepresentation,
});
} finally {
chunker.free();
// ^ is this really needed ?
}
}

if (xorb.offset > 0) {
yield xorb.event(chunkModule.compute_xorb_hash.bind(chunkModule));
}
if (xorb.offset > 0) {
yield xorb.event(chunkModule.compute_xorb_hash.bind(chunkModule));
}

for (const event of pendingFileEvents) {
event.representation = event.representation.map((rep) => ({
...rep,
xorbId: (rep.xorbId as number) >= 0 ? rep.xorbId : remoteXorbHashes[-rep.xorbId],
}));
yield event;
}
} finally {
chunker.free();
// ^ is this really needed ?
for (const event of pendingFileEvents) {
event.representation = event.representation.map((rep) => ({
...rep,
xorbId: (rep.xorbId as number) >= 0 ? rep.xorbId : remoteXorbHashes[-rep.xorbId],
}));
yield event;
}
}

Expand Down
Loading