Skip to content

Commit

Permalink
chore: export hash for uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 21, 2024
1 parent c9da728 commit 76650be
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ license = "MIT OR Apache-2.0"

[workspace.dependencies]
bytes = "1"
base64 = "0.21"
base64 = "0.22"
candid = "0.10"
ciborium = "0.2"
futures = "0.3"
Expand Down
1 change: 1 addition & 0 deletions src/ic_oss_ts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface UploadFileChunksResult {
id: number
filled: number
uploadedChunks: number[]
hash: Uint8Array | null
}

export interface Progress {
Expand Down
11 changes: 8 additions & 3 deletions src/ic_oss_ts/src/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export class Uploader {
return {
id: res.id,
filled: size,
uploadedChunks: []
uploadedChunks: [],
hash
}
}

Expand Down Expand Up @@ -100,7 +101,8 @@ export class Uploader {
const rt: UploadFileChunksResult = {
id,
filled: 0,
uploadedChunks: []
uploadedChunks: [],
hash
}

try {
Expand Down Expand Up @@ -146,10 +148,13 @@ export class Uploader {
}

await queue.wait()
if (!rt.hash) {
rt.hash = hasher.digest()
}
await this.#cli.updateFileInfo({
id,
status: this.setReadonly ? [1] : [],
hash: [hash || hasher.digest()],
hash: [rt.hash],
custom: [],
name: [],
size: [BigInt(size)],
Expand Down

0 comments on commit 76650be

Please sign in to comment.