From 777bc3b89da75313e2059af3f4fd3008f1726f5d Mon Sep 17 00:00:00 2001 From: Yingwen Date: Tue, 30 Apr 2024 17:40:11 +0800 Subject: [PATCH] fix: compiler warnings on Windows (#3844) * chore: fix windows warnings * test: try fix create_metadata_region on windows * style: fix clippy * style: fix clippy --- src/common/datasource/src/object_store.rs | 2 +- src/metric-engine/src/test_util.rs | 29 ++++++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/common/datasource/src/object_store.rs b/src/common/datasource/src/object_store.rs index c9e36018c22b..d2ed0a4ad82d 100644 --- a/src/common/datasource/src/object_store.rs +++ b/src/common/datasource/src/object_store.rs @@ -35,7 +35,7 @@ pub fn parse_url(url: &str) -> Result<(String, Option, String)> { #[cfg(windows)] { // On Windows, the url may start with `C:/`. - if let Some(_) = handle_windows_path(url) { + if handle_windows_path(url).is_some() { return Ok((FS_SCHEMA.to_string(), None, url.to_string())); } } diff --git a/src/metric-engine/src/test_util.rs b/src/metric-engine/src/test_util.rs index 2da459419d65..79a523bb5758 100644 --- a/src/metric-engine/src/test_util.rs +++ b/src/metric-engine/src/test_util.rs @@ -291,7 +291,8 @@ pub fn build_rows(num_tags: usize, num_rows: usize) -> Vec { #[cfg(test)] mod test { - + use object_store::services::Fs; + use object_store::ObjectStore; use store_api::metric_engine_consts::{DATA_REGION_SUBDIR, METADATA_REGION_SUBDIR}; use super::*; @@ -302,21 +303,21 @@ mod test { let env = TestEnv::new().await; env.init_metric_region().await; let region_id = to_metadata_region_id(env.default_physical_region_id()); - let region_dir = join_dir(&env.data_home(), "test_metric_region"); - // `join_dir` doesn't suit windows path - #[cfg(not(target_os = "windows"))] - { - // assert metadata region's dir - let metadata_region_dir = join_dir(®ion_dir, METADATA_REGION_SUBDIR); - let exist = tokio::fs::try_exists(metadata_region_dir).await.unwrap(); - assert!(exist); + let mut builder = Fs::default(); + builder.root(&env.data_home()); + let object_store = ObjectStore::new(builder).unwrap().finish(); - // assert data region's dir - let data_region_dir = join_dir(®ion_dir, DATA_REGION_SUBDIR); - let exist = tokio::fs::try_exists(data_region_dir).await.unwrap(); - assert!(exist); - } + let region_dir = "test_metric_region"; + // assert metadata region's dir + let metadata_region_dir = join_dir(region_dir, METADATA_REGION_SUBDIR); + let exist = object_store.is_exist(&metadata_region_dir).await.unwrap(); + assert!(exist); + + // assert data region's dir + let data_region_dir = join_dir(region_dir, DATA_REGION_SUBDIR); + let exist = object_store.is_exist(&data_region_dir).await.unwrap(); + assert!(exist); // check mito engine let metadata_region_id = utils::to_metadata_region_id(region_id);