Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: FsBuilder can't be used with empty root anymore #1293

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bindings/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use opendal::Operator;

#[napi]
pub fn debug() -> String {
let op = Operator::from_env::<services::Fs>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
format!("{:?}", op.metadata())
}
4 changes: 3 additions & 1 deletion bindings/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ mod tests {

#[tokio::test]
async fn test_basic() {
let op = Operator::from_env::<services::Memory>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
let object_store: Arc<dyn ObjectStore> = Arc::new(OpendalStore::new(op));

// Retrieve a specific file
Expand Down
4 changes: 3 additions & 1 deletion bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use pyo3::prelude::*;

#[pyfunction]
fn debug() -> PyResult<String> {
let op = Operator::from_env::<services::Fs>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
Ok(format!("{:?}", op.metadata()))
}

Expand Down
2 changes: 1 addition & 1 deletion src/layers/chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(ChaosLayer::new(0.1))
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/concurrent_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(ConcurrentLimitLayer::new(1024))
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(LoggingLayer::default())
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static LABEL_ERROR: &str = "error";
/// use opendal::services;
/// use opendal::Operator;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(MetricsLayer)
/// .finish();
Expand Down
4 changes: 2 additions & 2 deletions src/layers/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(RetryLayer::new(ExponentialBackoff::default()))
/// .finish();
Expand All @@ -64,7 +64,7 @@ where
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(RetryLayer::new(ExponentialBackoff::default()));
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/layers/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::*;
/// use opendal::services;
/// use opendal::Operator;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(TracingLayer)
/// .finish();
Expand Down
14 changes: 12 additions & 2 deletions src/raw/io/output/into_reader/by_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ impl<A: Accessor> output::Read for RangeReader<A> {
// TODO
//
// we can use RpRead returned here to correct size.
let (_, r) = ready!(Pin::new(fut).poll(cx))?;
let (_, r) = ready!(Pin::new(fut).poll(cx)).map_err(|err| {
// If read future retruns an error, we should reset
// state to Idle so that we can retry it.
self.state = State::Idle;
err
})?;

self.state = State::Reading(r);
self.poll_read(cx, buf)
Expand Down Expand Up @@ -230,7 +235,12 @@ impl<A: Accessor> output::Read for RangeReader<A> {
// TODO
//
// we can use RpRead returned here to correct size.
let (_, r) = ready!(Pin::new(fut).poll(cx))?;
let (_, r) = ready!(Pin::new(fut).poll(cx)).map_err(|err| {
// If read future retruns an error, we should reset
// state to Idle so that we can retry it.
self.state = State::Idle;
err
})?;

self.state = State::Reading(r);
self.poll_next(cx)
Expand Down
4 changes: 2 additions & 2 deletions src/raw/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod tests {
use futures::lock::Mutex;

use super::*;
use crate::services::Fs;
use crate::services::Memory;

#[derive(Debug)]
struct Test<A: Accessor> {
Expand Down Expand Up @@ -353,7 +353,7 @@ mod tests {
deleted: Arc::new(Mutex::new(false)),
};

let op = Operator::create(Fs::default())
let op = Operator::create(Memory::default())
.unwrap()
.layer(&test)
.finish();
Expand Down