Skip to content

Commit

Permalink
feat: add batch_delete_subfiles API; improve store::fs
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Jul 7, 2024
1 parent 4580fe9 commit fcb380f
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 111 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# `ic-oss`

A decentralized Object Storage Service on the Internet Computer.
🗂 A decentralized Object Storage Service on the Internet Computer.

## Overview

Expand Down
46 changes: 24 additions & 22 deletions src/ic-oss-bucket/ic-oss-bucket.did
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ type InitArgs = record {
};
type MoveInput = record { id : nat32; to : nat32; from : nat32 };
type Result = variant { Ok; Err : text };
type Result_1 = variant { Ok : CreateFileOutput; Err : text };
type Result_2 = variant { Ok : bool; Err : text };
type Result_3 = variant { Ok : Bucket; Err };
type Result_4 = variant { Ok : vec record { nat32; blob }; Err : text };
type Result_5 = variant { Ok : FileInfo; Err : text };
type Result_6 = variant { Ok : FolderInfo; Err : text };
type Result_7 = variant { Ok : UpdateFileOutput; Err : text };
type Result_8 = variant { Ok : UpdateFileChunkOutput; Err : text };
type Result_1 = variant { Ok : vec nat32; Err : text };
type Result_2 = variant { Ok : CreateFileOutput; Err : text };
type Result_3 = variant { Ok : bool; Err : text };
type Result_4 = variant { Ok : Bucket; Err };
type Result_5 = variant { Ok : vec record { nat32; blob }; Err : text };
type Result_6 = variant { Ok : FileInfo; Err : text };
type Result_7 = variant { Ok : FolderInfo; Err : text };
type Result_8 = variant { Ok : UpdateFileOutput; Err : text };
type Result_9 = variant { Ok : UpdateFileChunkOutput; Err : text };
type StreamingCallbackHttpResponse = record {
token : opt StreamingCallbackToken;
body : blob;
Expand Down Expand Up @@ -150,28 +151,29 @@ service : (opt CanisterArgs) -> {
admin_set_auditors : (vec principal) -> (Result);
admin_set_managers : (vec principal) -> (Result);
api_version : () -> (nat16) query;
create_file : (CreateFileInput, opt blob) -> (Result_1);
create_folder : (CreateFolderInput, opt blob) -> (Result_1);
delete_file : (nat32, opt blob) -> (Result_2);
delete_folder : (nat32, opt blob) -> (Result_2);
get_bucket_info : (opt blob) -> (Result_3) query;
batch_delete_subfiles : (nat32, vec nat32, opt blob) -> (Result_1);
create_file : (CreateFileInput, opt blob) -> (Result_2);
create_folder : (CreateFolderInput, opt blob) -> (Result_2);
delete_file : (nat32, opt blob) -> (Result_3);
delete_folder : (nat32, opt blob) -> (Result_3);
get_bucket_info : (opt blob) -> (Result_4) query;
get_file_ancestors : (nat32, opt blob) -> (vec FolderName) query;
get_file_chunks : (nat32, nat32, opt nat32, opt blob) -> (Result_4) query;
get_file_info : (nat32, opt blob) -> (Result_5) query;
get_file_info_by_hash : (blob, opt blob) -> (Result_5) query;
get_file_chunks : (nat32, nat32, opt nat32, opt blob) -> (Result_5) query;
get_file_info : (nat32, opt blob) -> (Result_6) query;
get_file_info_by_hash : (blob, opt blob) -> (Result_6) query;
get_folder_ancestors : (nat32, opt blob) -> (vec FolderName) query;
get_folder_info : (nat32, opt blob) -> (Result_6) query;
get_folder_info : (nat32, opt blob) -> (Result_7) query;
http_request : (HttpRequest) -> (HttpStreamingResponse) query;
http_request_streaming_callback : (StreamingCallbackToken) -> (
StreamingCallbackHttpResponse,
) query;
list_files : (nat32, opt nat32, opt nat32, opt blob) -> (vec FileInfo) query;
list_folders : (nat32, opt blob) -> (vec FolderInfo) query;
move_file : (MoveInput, opt blob) -> (Result_7);
move_folder : (MoveInput, opt blob) -> (Result_7);
update_file_chunk : (UpdateFileChunkInput, opt blob) -> (Result_8);
update_file_info : (UpdateFileInput, opt blob) -> (Result_7);
update_folder_info : (UpdateFolderInput, opt blob) -> (Result_7);
move_file : (MoveInput, opt blob) -> (Result_8);
move_folder : (MoveInput, opt blob) -> (Result_8);
update_file_chunk : (UpdateFileChunkInput, opt blob) -> (Result_9);
update_file_info : (UpdateFileInput, opt blob) -> (Result_8);
update_folder_info : (UpdateFolderInput, opt blob) -> (Result_8);
validate_admin_set_auditors : (vec principal) -> (Result);
validate_admin_set_managers : (vec principal) -> (Result);
}
10 changes: 10 additions & 0 deletions src/ic-oss-bucket/src/api_update.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use ic_oss_types::{crc32, file::*, folder::*, to_cbor_bytes};
use serde_bytes::ByteBuf;
use std::collections::BTreeSet;

use crate::{is_controller_or_manager, store, MILLISECONDS};

Expand Down Expand Up @@ -156,6 +157,15 @@ fn delete_file(id: u32, _access_token: Option<ByteBuf>) -> Result<bool, String>
store::fs::delete_file(id)
}

#[ic_cdk::update(guard = "is_controller_or_manager")]
fn batch_delete_subfiles(
parent: u32,
ids: BTreeSet<u32>,
_access_token: Option<ByteBuf>,
) -> Result<Vec<u32>, String> {
store::fs::batch_delete_subfiles(parent, ids)
}

#[ic_cdk::update(guard = "is_controller_or_manager")]
fn create_folder(
input: CreateFolderInput,
Expand Down
Loading

0 comments on commit fcb380f

Please sign in to comment.