Skip to content

Commit 66299a3

Browse files
committed
fixup! add dedup ratio to information
1 parent 5f3a61b commit 66299a3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/hub/src/utils/createXorbs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MAX_XORB_CHUNKS = 8 * 1024;
1818
const INTERVAL_BETWEEN_REMOTE_DEDUP = 4_000_000; // 4MB
1919

2020
export async function* createXorbs(
21-
fileSources: AsyncGenerator<{ content: Blob; path: string }>,
21+
fileSources: AsyncGenerator<{ content: Blob; path: string; sha256: string }>,
2222
params: XetWriteTokenParams
2323
): AsyncGenerator<
2424
| {
@@ -36,6 +36,7 @@ export async function* createXorbs(
3636
event: "file";
3737
path: string;
3838
hash: string;
39+
sha256: string;
3940
/** Percentage of file bytes that were deduplicated (0-1) */
4041
dedupRatio: number;
4142
representation: Array<{
@@ -77,6 +78,7 @@ export async function* createXorbs(
7778
path: string;
7879
hash: string;
7980
dedupRatio: number;
81+
sha256: string;
8082
representation: Array<{
8183
xorbId: number | string;
8284
offset: number;
@@ -281,6 +283,7 @@ export async function* createXorbs(
281283
event: "file" as const,
282284
path: fileSource.path,
283285
hash: chunkModule.compute_file_hash(fileChunks),
286+
sha256: fileSource.sha256,
284287
dedupRatio,
285288
representation: fileRepresentation,
286289
});

packages/hub/src/utils/uploadShards.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export async function* uploadShards(
6868
source: AsyncGenerator<{ content: Blob; path: string; sha256: string }>,
6969
params: UploadShardsParams
7070
): AsyncGenerator<
71-
{ event: "file"; path: string; sha256: string } | { event: "fileProgress"; path: string; progress: number }
71+
| { event: "file"; path: string; sha256: string; dedupRatio: number }
72+
| { event: "fileProgress"; path: string; progress: number }
7273
> {
7374
const xorbHashes: Array<string> = [];
7475

@@ -136,7 +137,7 @@ export async function* uploadShards(
136137
break;
137138
}
138139
case "file": {
139-
yield { event: "file", path: output.path, sha256: output.sha256 }; // Maybe wait until shard is uploaded before yielding.
140+
yield { event: "file", path: output.path, sha256: output.sha256, dedupRatio: output.dedupRatio }; // Maybe wait until shard is uploaded before yielding.
140141

141142
// Calculate space needed for this file entry
142143
const fileHeaderSize = HASH_LENGTH + 4 + 4 + 8; // hash + flags + rep length + reserved

0 commit comments

Comments
 (0)