Skip to content

Commit

Permalink
fix: lint & delete test case
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Nov 25, 2023
1 parent a1a5c68 commit 2174e49
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libs/jwst-codec-utils/src/doc_operation/yrs_op/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn yrs_create_nest_type_from_root(doc: &yrs::Doc, target_type: CRDTNestType,
}
}

pub fn gen_nest_type_from_root(doc: &mut Doc, crdt_param: &CRDTParam) -> Option<YrsNestType> {
pub fn gen_nest_type_from_root(doc: &Doc, crdt_param: &CRDTParam) -> Option<YrsNestType> {
match crdt_param.new_nest_type {
CRDTNestType::Array => Some(yrs_create_nest_type_from_root(
doc,
Expand Down Expand Up @@ -124,7 +124,7 @@ pub fn gen_nest_type_from_root(doc: &mut Doc, crdt_param: &CRDTParam) -> Option<
}

pub fn gen_nest_type_from_nest_type(
doc: &mut Doc,
doc: &Doc,
crdt_param: CRDTParam,
nest_type: &mut YrsNestType,
) -> Option<YrsNestType> {
Expand Down
11 changes: 7 additions & 4 deletions libs/jwst-storage/src/storage/blobs/auto_storage/auto_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl BlobAutoStorage {
.map(|c| c > 0)?)
}

async fn insert(&self, table: &str, hash: &str, params: &str, blob: &[u8]) -> JwstBlobResult<()> {
async fn insert(&self, workspace: &str, hash: &str, params: &str, blob: &[u8]) -> JwstBlobResult<()> {
if let Some(model) = OptimizedBlobs::find_by_id((workspace.into(), hash.into(), params.into()))
.one(&self.pool)
.await?
Expand All @@ -47,12 +47,13 @@ impl BlobAutoStorage {
}
} else {
OptimizedBlobs::insert(OptimizedBlobActiveModel {
workspace_id: Set(table.into()),
workspace_id: Set(workspace.into()),
hash: Set(hash.into()),
blob: Set(blob.into()),
length: Set(blob.len().try_into().unwrap()),
params: Set(params.into()),
created_at: Set(Utc::now().into()),
deleted_at: Set(None),
})
.exec(&self.pool)
.await?;
Expand Down Expand Up @@ -152,14 +153,16 @@ impl BlobAutoStorage {
}
}

async fn delete(&self, table: &str, hash: &str) -> JwstBlobResult<u64> {
async fn delete(&self, workspace: &str, hash: &str) -> JwstBlobResult<u64> {
OptimizedBlobs::update_many()
.col_expr(OptimizedBlobColumn::DeletedAt, Expr::value(Utc::now()))
.filter(OptimizedBlobColumn::WorkspaceId.eq(workspace))
.filter(OptimizedBlobColumn::Hash.eq(hash))
.filter(OptimizedBlobColumn::DeletedAt.is_null())
.exec(&self.pool)
.await
.map(|r| r.rows_affected == 1)
.map(|r| r.rows_affected)
.map_err(|e| e.into())
}

async fn drop(&self, table: &str) -> Result<(), DbErr> {
Expand Down
2 changes: 2 additions & 0 deletions libs/jwst-storage/src/storage/blobs/blob_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl BlobDBStorage {
.select_only()
.column_as(BlobColumn::Length, "size")
.column_as(BlobColumn::CreatedAt, "created_at")
.filter(BlobColumn::DeletedAt.is_null())
.into_model::<InternalBlobMetadata>()
.one(&self.pool)
.await
Expand Down Expand Up @@ -139,6 +140,7 @@ impl BlobDBStorage {
.col_expr(BlobColumn::DeletedAt, Expr::value(Utc::now()))
.filter(BlobColumn::WorkspaceId.eq(workspace))
.filter(BlobColumn::Hash.eq(hash))
.filter(BlobColumn::DeletedAt.is_null())
.exec(&self.pool)
.await
.map(|r| r.rows_affected == 1)
Expand Down

0 comments on commit 2174e49

Please sign in to comment.