Skip to content

Commit

Permalink
fix: merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Sep 27, 2023
1 parent 90ba069 commit e4ff5ce
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/jwst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: fuzzing
working-directory: ./libs/jwst-codec
working-directory: ./libs/jwst-codec-utils
run: |
cargo install cargo-fuzz
cargo fuzz run apply_update -- -max_total_time=30
Expand All @@ -463,4 +463,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: fuzz-artifact
path: ./lib/jwst-codec/fuzz/artifacts/**/*
path: ./lib/jwst-codec-utils/fuzz/artifacts/**/*
6 changes: 0 additions & 6 deletions libs/jwst-codec-utils/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ test = false
doc = false

[patch.crates-io]
<<<<<<<< HEAD:libs/jwst-codec/fuzz/Cargo.toml

========

>>>>>>>> 07723fc (feat: move compatibility test to utils (#27)):y-octo-utils/fuzz/Cargo.tomllib0 = { git = "https://github.com/toeverything/y-crdt", rev = "a700f09" }
yrs = { git = "https://github.com/toeverything/y-crdt", rev = "a700f09" }
lib0 = { git = "https://github.com/toeverything/y-crdt", rev = "a700f09" }
y-sync = { git = "https://github.com/toeverything/y-sync", rev = "5626851" }
yrs = { git = "https://github.com/toeverything/y-crdt", rev = "a700f09" }
4 changes: 0 additions & 4 deletions libs/jwst-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ proptest = "1.2"
proptest-derive = "0.4"
yrs = "=0.16.5"

[[bin]]
name = "memory_leak_test"
path = "bin/memory_leak_test.rs"

[[bench]]
harness = false
name = "array_ops_benchmarks"
Expand Down
2 changes: 1 addition & 1 deletion libs/jwst-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["DarkSky <[email protected]>"]
license = "AGPL-3.0-only"

[features]
default = ["sqlite"]
default = ["sqlite", "image", "bucket"]
bucket = ["dotenvy", "opendal"]
image = ["dep:image"]
mysql = ["sea-orm/sqlx-mysql"]
Expand Down
72 changes: 36 additions & 36 deletions libs/jwst-storage/src/storage/blobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pub enum JwstBlobError {
pub type JwstBlobResult<T> = Result<T, JwstBlobError>;

pub enum JwstBlobStorage {
RawStorage(Arc<BlobDBStorage>),
Raw(Arc<BlobDBStorage>),
#[cfg(feature = "image")]
AutoStorage(BlobAutoStorage),
Auto(BlobAutoStorage),
#[cfg(feature = "bucket")]
BucketStorage(BlobBucketStorage),
Bucket(BlobBucketStorage),
}

pub enum BlobStorageType {
Expand All @@ -57,21 +57,21 @@ pub enum BlobStorageType {
impl BlobStorage<JwstStorageError> for JwstBlobStorage {
async fn list_blobs(&self, workspace: Option<String>) -> JwstResult<Vec<String>, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.list_blobs(workspace).await,
JwstBlobStorage::Raw(db) => db.list_blobs(workspace).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.list_blobs(workspace).await,
JwstBlobStorage::Auto(db) => db.list_blobs(workspace).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.list_blobs(workspace).await,
JwstBlobStorage::Bucket(db) => db.list_blobs(workspace).await,
}
}

async fn check_blob(&self, workspace: Option<String>, id: String) -> JwstResult<bool, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.check_blob(workspace, id).await,
JwstBlobStorage::Raw(db) => db.check_blob(workspace, id).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.check_blob(workspace, id).await,
JwstBlobStorage::Auto(db) => db.check_blob(workspace, id).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.check_blob(workspace, id).await,
JwstBlobStorage::Bucket(db) => db.check_blob(workspace, id).await,
}
}

Expand All @@ -82,11 +82,11 @@ impl BlobStorage<JwstStorageError> for JwstBlobStorage {
params: Option<HashMap<String, String>>,
) -> JwstResult<Vec<u8>, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.get_blob(workspace, id, params).await,
JwstBlobStorage::Raw(db) => db.get_blob(workspace, id, params).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.get_blob(workspace, id, params).await,
JwstBlobStorage::Auto(db) => db.get_blob(workspace, id, params).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.get_blob(workspace, id, params).await,
JwstBlobStorage::Bucket(db) => db.get_blob(workspace, id, params).await,
}
}

Expand All @@ -97,11 +97,11 @@ impl BlobStorage<JwstStorageError> for JwstBlobStorage {
params: Option<HashMap<String, String>>,
) -> JwstResult<BlobMetadata, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.get_metadata(workspace, id, params).await,
JwstBlobStorage::Raw(db) => db.get_metadata(workspace, id, params).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.get_metadata(workspace, id, params).await,
JwstBlobStorage::Auto(db) => db.get_metadata(workspace, id, params).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.get_metadata(workspace, id, params).await,
JwstBlobStorage::Bucket(db) => db.get_metadata(workspace, id, params).await,
}
}

Expand All @@ -111,73 +111,73 @@ impl BlobStorage<JwstStorageError> for JwstBlobStorage {
stream: impl Stream<Item = Bytes> + Send,
) -> JwstResult<String, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.put_blob_stream(workspace, stream).await,
JwstBlobStorage::Raw(db) => db.put_blob_stream(workspace, stream).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.put_blob_stream(workspace, stream).await,
JwstBlobStorage::Auto(db) => db.put_blob_stream(workspace, stream).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.put_blob_stream(workspace, stream).await,
JwstBlobStorage::Bucket(db) => db.put_blob_stream(workspace, stream).await,
}
}

async fn put_blob(&self, workspace: Option<String>, blob: Vec<u8>) -> JwstResult<String, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.put_blob(workspace, blob).await,
JwstBlobStorage::Raw(db) => db.put_blob(workspace, blob).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.put_blob(workspace, blob).await,
JwstBlobStorage::Auto(db) => db.put_blob(workspace, blob).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.put_blob(workspace, blob).await,
JwstBlobStorage::Bucket(db) => db.put_blob(workspace, blob).await,
}
}

async fn delete_blob(&self, workspace: Option<String>, id: String) -> JwstResult<bool, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.delete_blob(workspace, id).await,
JwstBlobStorage::Raw(db) => db.delete_blob(workspace, id).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.delete_blob(workspace, id).await,
JwstBlobStorage::Auto(db) => db.delete_blob(workspace, id).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.delete_blob(workspace, id).await,
JwstBlobStorage::Bucket(db) => db.delete_blob(workspace, id).await,
}
}

async fn delete_workspace(&self, workspace_id: String) -> JwstResult<(), JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => db.delete_workspace(workspace_id).await,
JwstBlobStorage::Raw(db) => db.delete_workspace(workspace_id).await,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.delete_workspace(workspace_id).await,
JwstBlobStorage::Auto(db) => db.delete_workspace(workspace_id).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.delete_workspace(workspace_id).await,
JwstBlobStorage::Bucket(db) => db.delete_workspace(workspace_id).await,
}
}

async fn get_blobs_size(&self, workspaces: Vec<String>) -> JwstResult<i64, JwstStorageError> {
match self {
JwstBlobStorage::RawStorage(db) => Ok(db.get_blobs_size(&workspaces).await?.unwrap_or(0)),
JwstBlobStorage::Raw(db) => Ok(db.get_blobs_size(&workspaces).await?.unwrap_or(0)),
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => db.get_blobs_size(workspaces).await,
JwstBlobStorage::Auto(db) => db.get_blobs_size(workspaces).await,
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(db) => db.get_blobs_size(workspaces).await,
JwstBlobStorage::Bucket(db) => db.get_blobs_size(workspaces).await,
}
}
}

impl JwstBlobStorage {
pub fn get_blob_db(&self) -> Option<Arc<BlobDBStorage>> {
match self {
JwstBlobStorage::RawStorage(db) => Some(db.clone()),
JwstBlobStorage::Raw(db) => Some(db.clone()),
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(db) => Some(db.db.clone()),
JwstBlobStorage::Auto(db) => Some(db.db.clone()),
#[cfg(feature = "bucket")]
JwstBlobStorage::BucketStorage(_) => None,
JwstBlobStorage::Bucket(_) => None,
}
}

#[cfg(feature = "bucket")]
pub fn get_mixed_bucket_db(&self) -> Option<BlobBucketStorage> {
match self {
JwstBlobStorage::RawStorage(_) => None,
JwstBlobStorage::Raw(_) => None,
#[cfg(feature = "image")]
JwstBlobStorage::AutoStorage(_) => None,
JwstBlobStorage::BucketStorage(db) => Some(db.clone()),
JwstBlobStorage::Auto(_) => None,
JwstBlobStorage::Bucket(db) => Some(db.clone()),
}
}
}
6 changes: 3 additions & 3 deletions libs/jwst-storage/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ impl JwstStorage {
BlobStorageType::DB => {
#[cfg(feature = "image")]
{
JwstBlobStorage::AutoStorage(BlobAutoStorage::init_with_pool(pool.clone(), bucket.clone()).await?)
JwstBlobStorage::Auto(BlobAutoStorage::init_with_pool(pool.clone(), bucket.clone()).await?)
}
#[cfg(not(feature = "image"))]
{
let db = BlobDBStorage::init_with_pool(pool.clone(), bucket.clone()).await?;
JwstBlobStorage::RawStorage(Arc::new(db))
JwstBlobStorage::Raw(Arc::new(db))
}
}
#[cfg(feature = "bucket")]
BlobStorageType::MixedBucketDB(param) => JwstBlobStorage::BucketStorage(
BlobStorageType::MixedBucketDB(param) => JwstBlobStorage::Bucket(
BlobBucketStorage::init_with_pool(pool.clone(), bucket.clone(), Some(param.try_into()?)).await?,
),
};
Expand Down

0 comments on commit e4ff5ce

Please sign in to comment.