diff --git a/crates/scanner/src/data_usage.rs b/crates/scanner/src/data_usage.rs deleted file mode 100644 index cd8feeea..00000000 --- a/crates/scanner/src/data_usage.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2024 RustFS Team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use rustfs_ecstore::disk::{BUCKET_META_PREFIX, RUSTFS_META_BUCKET}; -use rustfs_utils::path::SLASH_SEPARATOR; -use std::sync::LazyLock; - -// Data usage constants -pub const DATA_USAGE_ROOT: &str = SLASH_SEPARATOR; - -const DATA_USAGE_OBJ_NAME: &str = ".usage.json"; - -const DATA_USAGE_BLOOM_NAME: &str = ".bloomcycle.bin"; - -pub const DATA_USAGE_CACHE_NAME: &str = ".usage-cache.bin"; - -// Data usage paths (computed at runtime) -pub static DATA_USAGE_BUCKET: LazyLock = - LazyLock::new(|| format!("{RUSTFS_META_BUCKET}{SLASH_SEPARATOR}{BUCKET_META_PREFIX}")); - -pub static DATA_USAGE_OBJ_NAME_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}{DATA_USAGE_OBJ_NAME}")); - -pub static DATA_USAGE_BLOOM_NAME_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}{DATA_USAGE_BLOOM_NAME}")); - -pub static BACKGROUND_HEAL_INFO_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}.background-heal.json")); diff --git a/crates/scanner/src/data_usage_define.rs b/crates/scanner/src/data_usage_define.rs index bd27c9b9..a8fda199 100644 --- a/crates/scanner/src/data_usage_define.rs +++ b/crates/scanner/src/data_usage_define.rs @@ -32,12 +32,12 @@ use rustfs_ecstore::{ error::{Error, Result as StorageResult, StorageError}, store_api::{ObjectInfo, ObjectOptions}, }; -use rustfs_utils::path::{SLASH_SEPARATOR, path_join_buf}; +use rustfs_utils::path::{SLASH_SEPARATOR_STR, path_join_buf}; use tokio::time::{Duration, sleep, timeout}; use tracing::{error, warn}; // Data usage constants -pub const DATA_USAGE_ROOT: &str = SLASH_SEPARATOR; +pub const DATA_USAGE_ROOT: &str = SLASH_SEPARATOR_STR; const DATA_USAGE_OBJ_NAME: &str = ".usage.json"; @@ -47,16 +47,16 @@ pub const DATA_USAGE_CACHE_NAME: &str = ".usage-cache.bin"; // Data usage paths (computed at runtime) pub static DATA_USAGE_BUCKET: LazyLock = - LazyLock::new(|| format!("{RUSTFS_META_BUCKET}{SLASH_SEPARATOR}{BUCKET_META_PREFIX}")); + LazyLock::new(|| format!("{RUSTFS_META_BUCKET}{SLASH_SEPARATOR_STR}{BUCKET_META_PREFIX}")); pub static DATA_USAGE_OBJ_NAME_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}{DATA_USAGE_OBJ_NAME}")); + LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR_STR}{DATA_USAGE_OBJ_NAME}")); pub static DATA_USAGE_BLOOM_NAME_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}{DATA_USAGE_BLOOM_NAME}")); + LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR_STR}{DATA_USAGE_BLOOM_NAME}")); pub static BACKGROUND_HEAL_INFO_PATH: LazyLock = - LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR}.background-heal.json")); + LazyLock::new(|| format!("{BUCKET_META_PREFIX}{SLASH_SEPARATOR_STR}.background-heal.json")); #[derive(Clone, Copy, Default, Debug, Serialize, Deserialize, PartialEq)] pub struct TierStats { diff --git a/crates/scanner/src/lib.rs b/crates/scanner/src/lib.rs index 94148fee..4dd3f543 100644 --- a/crates/scanner/src/lib.rs +++ b/crates/scanner/src/lib.rs @@ -20,7 +20,6 @@ rust_2018_idioms )] -pub mod data_usage; pub mod data_usage_define; pub mod error; pub mod last_minute; diff --git a/crates/scanner/src/scanner.rs b/crates/scanner/src/scanner.rs index 292007c9..7b1cf354 100644 --- a/crates/scanner/src/scanner.rs +++ b/crates/scanner/src/scanner.rs @@ -14,7 +14,7 @@ use std::sync::Arc; -use crate::data_usage::{BACKGROUND_HEAL_INFO_PATH, DATA_USAGE_BLOOM_NAME_PATH, DATA_USAGE_OBJ_NAME_PATH}; +use crate::data_usage_define::{BACKGROUND_HEAL_INFO_PATH, DATA_USAGE_BLOOM_NAME_PATH, DATA_USAGE_OBJ_NAME_PATH}; use crate::metrics::CurrentCycle; use crate::metrics::global_metrics; use crate::scanner_folder::data_usage_update_dir_cycles; diff --git a/crates/scanner/src/scanner_folder.rs b/crates/scanner/src/scanner_folder.rs index c8b549c7..c3435c0e 100644 --- a/crates/scanner/src/scanner_folder.rs +++ b/crates/scanner/src/scanner_folder.rs @@ -44,7 +44,7 @@ use rustfs_ecstore::pools::{path2_bucket_object, path2_bucket_object_with_base_p use rustfs_ecstore::store_api::{ObjectInfo, ObjectToDelete}; use rustfs_ecstore::store_utils::is_reserved_or_invalid_bucket; use rustfs_filemeta::{MetaCacheEntries, MetaCacheEntry, MetadataResolutionParams, ReplicationStatusType}; -use rustfs_utils::path::{SLASH_SEPARATOR, path_join_buf}; +use rustfs_utils::path::{SLASH_SEPARATOR_STR, path_join_buf}; use s3s::dto::{BucketLifecycleConfiguration, ObjectLockConfiguration}; use tokio::select; use tokio::sync::mpsc; @@ -110,7 +110,7 @@ impl ScannerItem { /// This converts a directory path like "bucket/dir1/dir2/file" to prefix="bucket/dir1/dir2" and object_name="file" pub fn transform_meta_dir(&mut self) { let prefix = self.prefix.clone(); // Clone to avoid borrow checker issues - let split: Vec<&str> = prefix.split(SLASH_SEPARATOR).collect(); + let split: Vec<&str> = prefix.split(SLASH_SEPARATOR_STR).collect(); if split.len() > 1 { let prefix_parts: Vec<&str> = split[..split.len() - 1].to_vec(); diff --git a/crates/scanner/src/scanner_io.rs b/crates/scanner/src/scanner_io.rs index e71fece4..9564b3e2 100644 --- a/crates/scanner/src/scanner_io.rs +++ b/crates/scanner/src/scanner_io.rs @@ -22,7 +22,7 @@ use rustfs_ecstore::set_disk::SetDisks; use rustfs_ecstore::store_api::{BucketInfo, BucketOptions, ObjectInfo}; use rustfs_ecstore::{StorageAPI, error::Result, store::ECStore}; use rustfs_filemeta::FileMeta; -use rustfs_utils::path::{SLASH_SEPARATOR, path_join_buf}; +use rustfs_utils::path::{SLASH_SEPARATOR_STR, path_join_buf}; use s3s::dto::{BucketLifecycleConfiguration, ReplicationConfiguration}; use std::collections::HashMap; use std::time::SystemTime; @@ -473,7 +473,7 @@ impl ScannerIOCache for SetDisks { #[async_trait::async_trait] impl ScannerIODisk for Disk { async fn get_size(&self, mut item: ScannerItem) -> Result { - if !item.path.ends_with(&format!("{SLASH_SEPARATOR}{STORAGE_FORMAT_FILE}")) { + if !item.path.ends_with(&format!("{SLASH_SEPARATOR_STR}{STORAGE_FORMAT_FILE}")) { return Err(StorageError::other("skip file".to_string())); }