From cbabd150aac54dcedda246ec1aa075e66d190198 Mon Sep 17 00:00:00 2001 From: Robert Bastian <robertbastian@google.com> Date: Thu, 20 Jul 2023 17:40:39 +0200 Subject: [PATCH 1/2] wip --- provider/fs/src/export/fs_exporter.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/provider/fs/src/export/fs_exporter.rs b/provider/fs/src/export/fs_exporter.rs index 83dd6ab1fbc..a313623fe18 100644 --- a/provider/fs/src/export/fs_exporter.rs +++ b/provider/fs/src/export/fs_exporter.rs @@ -177,8 +177,12 @@ impl DataExporter for FilesystemExporter { let mut path_buf = self.root.clone().into_os_string(); write!(&mut path_buf, "/{key}").expect("infallible"); - fs::create_dir_all(&path_buf) - .map_err(|e| DataError::from(e).with_path_context(&path_buf))?; + if !Path::new(&path_buf).exists() { + fs::create_dir_all(&path_buf) + .map_err(|e| DataError::from(e).with_path_context(&path_buf))?; + write!(&mut path_buf, "/.empty").expect("infallible"); + fs::File::create(Path::new(&path_buf))?; + } Ok(()) } From bb3ac81288dba3f6b176d4847a338d2f6a0f3482 Mon Sep 17 00:00:00 2001 From: Robert Bastian <robertbastian@google.com> Date: Thu, 20 Jul 2023 17:46:56 +0200 Subject: [PATCH 2/2] errs --- provider/adapters/src/fork/by_error.rs | 10 +++++----- provider/adapters/src/fork/predicates.rs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/provider/adapters/src/fork/by_error.rs b/provider/adapters/src/fork/by_error.rs index 2cde1aaaf74..5d25ce2072f 100644 --- a/provider/adapters/src/fork/by_error.rs +++ b/provider/adapters/src/fork/by_error.rs @@ -174,7 +174,7 @@ where key: DataKey, req: DataRequest, ) -> Result<DataResponse<BufferMarker>, DataError> { - let mut last_error = DataErrorKind::MissingDataKey.with_key(key); + let mut last_error = F::UNIT_ERROR.with_key(key); for provider in self.providers.iter() { let result = provider.load_buffer(key, req); match result { @@ -193,7 +193,7 @@ where F: ForkByErrorPredicate, { fn load_any(&self, key: DataKey, req: DataRequest) -> Result<AnyResponse, DataError> { - let mut last_error = DataErrorKind::MissingDataKey.with_key(key); + let mut last_error = F::UNIT_ERROR.with_key(key); for provider in self.providers.iter() { let result = provider.load_any(key, req); match result { @@ -213,7 +213,7 @@ where F: ForkByErrorPredicate, { fn load_data(&self, key: DataKey, req: DataRequest) -> Result<DataResponse<M>, DataError> { - let mut last_error = DataErrorKind::MissingDataKey.with_key(key); + let mut last_error = F::UNIT_ERROR.with_key(key); for provider in self.providers.iter() { let result = provider.load_data(key, req); match result { @@ -234,7 +234,7 @@ where F: ForkByErrorPredicate, { fn supported_locales_for_key(&self, key: DataKey) -> Result<Vec<DataLocale>, DataError> { - let mut last_error = F::ERROR.with_key(key); + let mut last_error = F::UNIT_ERROR.with_key(key); for provider in self.providers.iter() { let result = provider.supported_locales_for_key(key); match result { @@ -260,7 +260,7 @@ where key: DataKey, mut from: DataPayload<MFrom>, ) -> Result<DataPayload<MTo>, (DataPayload<MFrom>, DataError)> { - let mut last_error = F::ERROR.with_key(key); + let mut last_error = F::UNIT_ERROR.with_key(key); for provider in self.providers.iter() { let result = provider.convert(key, from); match result { diff --git a/provider/adapters/src/fork/predicates.rs b/provider/adapters/src/fork/predicates.rs index 2905d63bc77..58ffa741635 100644 --- a/provider/adapters/src/fork/predicates.rs +++ b/provider/adapters/src/fork/predicates.rs @@ -11,7 +11,7 @@ use icu_provider::prelude::*; /// [`ForkByErrorProvider`]: super::ForkByErrorProvider pub trait ForkByErrorPredicate { /// The error to return if there are zero providers. - const ERROR: DataErrorKind = DataErrorKind::MissingDataKey; + const UNIT_ERROR: DataErrorKind = DataErrorKind::MissingDataKey; /// This function is called when a data request fails and there are additional providers /// that could possibly fulfill the request. @@ -46,7 +46,7 @@ pub trait ForkByErrorPredicate { pub struct MissingDataKeyPredicate; impl ForkByErrorPredicate for MissingDataKeyPredicate { - const ERROR: DataErrorKind = DataErrorKind::MissingDataKey; + const UNIT_ERROR: DataErrorKind = DataErrorKind::MissingDataKey; #[inline] fn test(&self, _: DataKey, _: Option<DataRequest>, err: DataError) -> bool { @@ -130,7 +130,7 @@ impl ForkByErrorPredicate for MissingDataKeyPredicate { pub struct MissingLocalePredicate; impl ForkByErrorPredicate for MissingLocalePredicate { - const ERROR: DataErrorKind = DataErrorKind::MissingLocale; + const UNIT_ERROR: DataErrorKind = DataErrorKind::MissingLocale; #[inline] fn test(&self, _: DataKey, _: Option<DataRequest>, err: DataError) -> bool {