From 4a63cb485175d917f917519b6ae4c7fb3845ae1b Mon Sep 17 00:00:00 2001 From: "Chanyub.Park" Date: Mon, 2 Sep 2024 17:37:11 +0900 Subject: [PATCH] no_hardlinks to disable_hardlinks --- object_store_factory/src/local.rs | 36 +++++++++++++++---------------- src/config/schema.rs | 4 ++-- src/context/delta.rs | 2 +- src/object_store/wrapped.rs | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/object_store_factory/src/local.rs b/object_store_factory/src/local.rs index 6ca3d782..9d107a42 100644 --- a/object_store_factory/src/local.rs +++ b/object_store_factory/src/local.rs @@ -7,7 +7,7 @@ use std::sync::Arc; pub struct LocalConfig { pub data_dir: String, #[serde(default = "default_false")] - pub no_hardlinks: bool, + pub disable_hardlinks: bool, } fn default_false() -> bool { @@ -25,14 +25,14 @@ impl LocalConfig { source: "Missing data_dir".into(), })? .clone(), - no_hardlinks: map.get("no_hardlinks").map(|s| s == "true").unwrap_or(false), + disable_hardlinks: map.get("disable_hardlinks").map(|s| s == "true").unwrap_or(false), }) } pub fn to_hashmap(&self) -> HashMap { let mut map = HashMap::new(); map.insert("data_dir".to_string(), self.data_dir.clone()); - map.insert("no_hardlinks".to_string(), self.no_hardlinks.to_string()); + map.insert("disable_hardlinks".to_string(), self.disable_hardlinks.to_string()); map } @@ -57,31 +57,31 @@ mod tests { let config = LocalConfig::from_hashmap(&map) .expect("Failed to create config from hashmap"); assert_eq!(config.data_dir, "/tmp/data".to_string()); - assert_eq!(config.no_hardlinks, false); // Default value + assert_eq!(config.disable_hardlinks, false); // Default value } #[test] - fn test_config_from_hashmap_with_no_hardlinks() { + fn test_config_from_hashmap_with_disable_hardlinks() { let mut map = HashMap::new(); map.insert("data_dir".to_string(), "/tmp/data".to_string()); - map.insert("no_hardlinks".to_string(), "true".to_string()); + map.insert("disable_hardlinks".to_string(), "true".to_string()); let config = LocalConfig::from_hashmap(&map) .expect("Failed to create config from hashmap"); assert_eq!(config.data_dir, "/tmp/data".to_string()); - assert_eq!(config.no_hardlinks, true); + assert_eq!(config.disable_hardlinks, true); } #[test] - fn test_config_from_hashmap_with_no_hardlinks_false() { + fn test_config_from_hashmap_with_disable_hardlinks_false() { let mut map = HashMap::new(); map.insert("data_dir".to_string(), "/tmp/data".to_string()); - map.insert("no_hardlinks".to_string(), "false".to_string()); + map.insert("disable_hardlinks".to_string(), "false".to_string()); let config = LocalConfig::from_hashmap(&map) .expect("Failed to create config from hashmap"); assert_eq!(config.data_dir, "/tmp/data".to_string()); - assert_eq!(config.no_hardlinks, false); + assert_eq!(config.disable_hardlinks, false); } #[test] @@ -102,7 +102,7 @@ mod tests { let result = LocalConfig { data_dir: data_dir.to_string(), - no_hardlinks: false, + disable_hardlinks: false, } .build_local_storage(); assert!(result.is_ok(), "Expected Ok, got Err: {:?}", result); @@ -112,7 +112,7 @@ mod tests { fn test_build_local_storage_with_invalid_path() { let result = LocalConfig { data_dir: "".to_string(), - no_hardlinks: false, + disable_hardlinks: false, } .build_local_storage(); assert!(result.is_err(), "Expected Err due to invalid path, got Ok"); @@ -122,13 +122,13 @@ mod tests { fn test_to_hashmap() { let local_config = LocalConfig { data_dir: "path/to/data".to_string(), - no_hardlinks: true, + disable_hardlinks: true, }; let hashmap = local_config.to_hashmap(); assert_eq!(hashmap.get("data_dir"), Some(&"path/to/data".to_string())); - assert_eq!(hashmap.get("no_hardlinks"), Some(&"true".to_string())); + assert_eq!(hashmap.get("disable_hardlinks"), Some(&"true".to_string())); } #[test] @@ -146,20 +146,20 @@ mod tests { let config: LocalConfig = serde_json::from_str(json).unwrap(); assert_eq!(config.data_dir, "/tmp/data"); - assert_eq!(config.no_hardlinks, false); + assert_eq!(config.disable_hardlinks, false); } #[test] - fn test_deserialize_with_no_hardlinks() { + fn test_deserialize_with_disable_hardlinks() { let json = r#" { "data_dir": "/tmp/data", - "no_hardlinks": true + "disable_hardlinks": true } "#; let config: LocalConfig = serde_json::from_str(json).unwrap(); assert_eq!(config.data_dir, "/tmp/data"); - assert_eq!(config.no_hardlinks, true); + assert_eq!(config.disable_hardlinks, true); } } \ No newline at end of file diff --git a/src/config/schema.rs b/src/config/schema.rs index d7bc35b4..fd271939 100644 --- a/src/config/schema.rs +++ b/src/config/schema.rs @@ -637,7 +637,7 @@ cache_control = "private, max-age=86400" SeafowlConfig { object_store: Some(ObjectStoreConfig::Local(LocalConfig { data_dir: "./seafowl-data".to_string(), - no_hardlinks: false, + disable_hardlinks: false, })), catalog: Some(Catalog::Postgres(Postgres { dsn: "postgresql://user:pass@localhost:5432/somedb".to_string(), @@ -733,7 +733,7 @@ cache_control = "private, max-age=86400" SeafowlConfig { object_store: Some(ObjectStoreConfig::Local(LocalConfig { data_dir: "some_other_path".to_string(), - no_hardlinks: false, + disable_hardlinks: false, })), catalog: Some(Catalog::Sqlite(Sqlite { dsn: "sqlite://file.sqlite".to_string(), diff --git a/src/context/delta.rs b/src/context/delta.rs index a97e5c87..375480c2 100644 --- a/src/context/delta.rs +++ b/src/context/delta.rs @@ -528,7 +528,7 @@ mod tests { Arc::new(LocalFileSystem::new_with_prefix(tmp_dir.path()).unwrap()), ObjectStoreConfig::Local(LocalConfig { data_dir: tmp_dir.path().to_string_lossy().to_string(), - no_hardlinks: false, + disable_hardlinks: false, }), ), Some(tmp_dir), diff --git a/src/object_store/wrapped.rs b/src/object_store/wrapped.rs index 35a0f624..04f1eba2 100644 --- a/src/object_store/wrapped.rs +++ b/src/object_store/wrapped.rs @@ -240,7 +240,7 @@ impl ObjectStore for InternalObjectStore { /// /// Will return an error if the destination already has an object. async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> { - if let ObjectStoreConfig::Local(LocalConfig { no_hardlinks: true, .. }) = self.config { + if let ObjectStoreConfig::Local(LocalConfig { disable_hardlinks: true, .. }) = self.config { return self.inner.copy(from, to).await; } self.inner.copy_if_not_exists(from, to).await @@ -258,7 +258,7 @@ impl ObjectStore for InternalObjectStore { // this with a lock too, so look into using that down the line instead. return self.inner.rename(from, to).await; } - if let ObjectStoreConfig::Local(LocalConfig { no_hardlinks: true, .. }) = self.config { + if let ObjectStoreConfig::Local(LocalConfig { disable_hardlinks: true, .. }) = self.config { return self.inner.rename(from, to).await; } self.inner.rename_if_not_exists(from, to).await