Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Jul 6, 2024
1 parent dfdcf78 commit f029e25
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 97 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ jobs:
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: -p ic-oss-types -p ic-oss ic-oss-cli
ignore-unpublished-changes: true
args: -p ic-oss-types
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
ignore-unpublished-changes: true
args: -p ic-oss
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
ignore-unpublished-changes: true
args: -p ic-oss-cli
94 changes: 47 additions & 47 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ lint:
fix:
@cargo clippy --fix --workspace --tests

test:
@cargo test --workspace -- --nocapture

# cargo install ic-wasm
build-wasm:
cargo build --release --target wasm32-unknown-unknown --package ic-oss-bucket
@cargo build --release --target wasm32-unknown-unknown --package ic-oss-bucket

# cargo install candid-extractor
build-did:
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In decentralized enterprise applications, `ic-oss` will be an essential infrastr

- [x] Supports large file uploads and downloads through file sharding, concurrent high-speed uploads, resumable uploads, and segmented downloads.
- [x] Provides data verification based on ICP's verification mechanisms to ensure file integrity during reading.
- [ ] Supports file directory tree.
- [x] Supports file directory tree.
- [ ] Access control with permissions for public, private, read-only, and write-only for files, folders, and buckets.
- [ ] Based on a file bucket and cluster architecture, with each bucket corresponding to a ICP canister, allowing for unlimited horizontal scalability.
- [ ] Compatible with S3 core API protocol and supports S3 SDK.
Expand All @@ -31,7 +31,19 @@ If you want to test your project locally, you can use the following commands:
Deploy the bucket canister:
```bash
dfx canister create --specified-id mmrxu-fqaaa-aaaap-ahhna-cai ic-oss-bucket
dfx deploy ic-oss-bucket

dfx deploy ic-oss-bucket --argument "(opt variant {Init =
record {
name = \"LDC Labs\";
file_id = 0;
max_file_size = 0;
max_folder_depth = 10;
max_children = 1000;
visibility = 0;
max_custom_data_size = 4096;
enable_hash_index = true;
}
})"
# Output:
# ...
# Installing code for canister ic-oss-bucket, with canister ID mmrxu-fqaaa-aaaap-ahhna-cai
Expand Down
13 changes: 12 additions & 1 deletion src/ic-oss-bucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ A bucket canister of [ic-oss](https://github.com/ldclabs/ic-oss).

Deploy to local network:
```bash
dfx deploy ic-oss-bucket
dfx deploy ic-oss-bucket --argument "(opt variant {Init =
record {
name = \"LDC Labs\";
file_id = 0;
max_file_size = 0;
max_folder_depth = 10;
max_children = 1000;
visibility = 0;
max_custom_data_size = 4096;
enable_hash_index = true;
}
})"
# Output:
# ...
# Installing code for canister ic-oss-bucket, with canister ID mmrxu-fqaaa-aaaap-ahhna-cai
Expand Down
9 changes: 9 additions & 0 deletions src/ic-oss-bucket/src/api_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ fn range_response(
MAX_CHUNK_SIZE as usize - 1
};

if end >= chunk.len() {
return HttpStreamingResponse {
status_code: 416,
headers,
body: ByteBuf::from(format!("invalid range at chunk {i}").to_bytes()),
..Default::default()
};
}

body.extend_from_slice(&chunk[start..=end]);
}

Expand Down
Loading

0 comments on commit f029e25

Please sign in to comment.