diff --git a/core/src/layers/blocking.rs b/core/src/layers/blocking.rs index 8deb767e6c1f..b192c4b32521 100644 --- a/core/src/layers/blocking.rs +++ b/core/src/layers/blocking.rs @@ -146,8 +146,12 @@ impl Layer for BlockingLayer { type LayeredAccess = BlockingAccessor; fn layer(&self, inner: A) -> Self::LayeredAccess { + let mut meta = inner.info().as_ref().clone(); + meta.full_capability_mut().blocking = true; + BlockingAccessor { inner, + meta: Arc::new(meta), handle: self.handle.clone(), } } @@ -156,7 +160,7 @@ impl Layer for BlockingLayer { #[derive(Clone, Debug)] pub struct BlockingAccessor { inner: A, - + meta: Arc, handle: Handle, } @@ -174,9 +178,7 @@ impl LayeredAccess for BlockingAccessor { } fn metadata(&self) -> Arc { - let mut meta = self.inner.info().as_ref().clone(); - meta.full_capability_mut().blocking = true; - meta.into() + self.meta.clone() } async fn create_dir(&self, path: &str, args: OpCreateDir) -> Result { diff --git a/core/src/layers/complete.rs b/core/src/layers/complete.rs index 17c0c6414a01..4808c4f29ef4 100644 --- a/core/src/layers/complete.rs +++ b/core/src/layers/complete.rs @@ -109,8 +109,15 @@ impl Layer for CompleteLayer { type LayeredAccess = CompleteAccessor; fn layer(&self, inner: A) -> Self::LayeredAccess { + let mut meta = inner.info().as_ref().clone(); + let cap = meta.full_capability_mut(); + + if cap.list && cap.write_can_empty { + cap.create_dir = true; + } + CompleteAccessor { - meta: inner.info(), + meta: meta.into(), inner: Arc::new(inner), } } @@ -376,14 +383,8 @@ impl LayeredAccess for CompleteAccessor { &self.inner } - // Todo: May move the logic to the implement of Layer::layer of CompleteAccessor fn metadata(&self) -> Arc { - let mut meta = (*self.meta).clone(); - let cap = meta.full_capability_mut(); - if cap.list && cap.write_can_empty { - cap.create_dir = true; - } - meta.into() + self.meta.clone() } async fn create_dir(&self, path: &str, args: OpCreateDir) -> Result { diff --git a/core/src/layers/immutable_index.rs b/core/src/layers/immutable_index.rs index 5e02472fab6a..130587f21ed9 100644 --- a/core/src/layers/immutable_index.rs +++ b/core/src/layers/immutable_index.rs @@ -74,8 +74,15 @@ impl Layer for ImmutableIndexLayer { type LayeredAccess = ImmutableIndexAccessor; fn layer(&self, inner: A) -> Self::LayeredAccess { + let mut meta = inner.info().as_ref().clone(); + + let cap = meta.full_capability_mut(); + cap.list = true; + cap.list_with_recursive = true; + ImmutableIndexAccessor { vec: self.vec.clone(), + meta: Arc::new(meta), inner, } } @@ -84,6 +91,7 @@ impl Layer for ImmutableIndexLayer { #[derive(Debug, Clone)] pub struct ImmutableIndexAccessor { inner: A, + meta: Arc, vec: Vec, } @@ -150,13 +158,7 @@ impl LayeredAccess for ImmutableIndexAccessor { /// Add list capabilities for underlying storage services. fn metadata(&self) -> Arc { - let mut meta = (*self.inner.info()).clone(); - - let cap = meta.full_capability_mut(); - cap.list = true; - cap.list_with_recursive = true; - - meta.into() + self.meta.clone() } async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> {