Skip to content

Commit

Permalink
fix: fix error catching in TS package
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Oct 20, 2024
1 parent cd7aacd commit b6f4404
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 18 deletions.
12 changes: 6 additions & 6 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 @@ -17,7 +17,7 @@ strip = true
opt-level = 's'

[workspace.package]
version = "0.9.5"
version = "0.9.6"
edition = "2021"
repository = "https://github.com/ldclabs/ic-oss"
keywords = ["file", "storage", "oss", "s3", "icp"]
Expand Down
15 changes: 8 additions & 7 deletions src/ic_oss_bucket/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,6 @@ pub mod fs {
}

checker(&file)?;

file.updated_at = now_ms;
file.filled += chunk.len() as u64;
if file.filled > max {
Expand All @@ -1313,16 +1312,18 @@ pub mod fs {
r.borrow_mut()
.insert(FileId(file_id, chunk_index), Chunk(chunk))
}) {
None => {
if file.chunks <= chunk_index {
file.chunks = chunk_index + 1;
}
}
None => {}
Some(old) => {
file.filled -= old.0.len() as u64;
if chunk_index < file.chunks {
file.filled = file.filled.saturating_sub(old.0.len() as u64);
}
}
}

if file.chunks <= chunk_index {
file.chunks = chunk_index + 1;
}

let filled = file.filled;
if file.size > 0 && filled > file.size {
Err(format!(
Expand Down
3 changes: 2 additions & 1 deletion src/ic_oss_ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ldclabs/ic_oss_ts",
"version": "0.9.5",
"version": "0.9.6",
"type": "module",
"description": "The Typescript version of the client SDK for the ic-oss cluster.",
"license": "MIT",
Expand All @@ -20,6 +20,7 @@
"files": [
"candid",
"dist",
"src",
"package.json",
"LICENSE",
"README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/ic_oss_ts/src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ConcurrencyQueue {

result
.then(() => (this.#total += 1))
.catch(this.#abort)
.catch((err) => this.#abort(err))
.finally(() => {
this.#pending.delete(fn)
this.#results.delete(result)
Expand Down
1 change: 0 additions & 1 deletion src/ic_oss_ts/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export interface UploadFileChunksResult {
id: number
filled: number
uploadedChunks: number[]
error?: unknown // if any error occurs during upload
}

export interface Progress {
Expand Down
3 changes: 2 additions & 1 deletion src/ic_oss_ts/src/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ export class Uploader {
content_type: []
})
} catch (err) {
rt.error = err
;(err as any).data = rt
throw err
}

return rt
Expand Down

0 comments on commit b6f4404

Please sign in to comment.