Skip to content

Commit fb291dc

Browse files
authored
feat(backend)!: remove s3 and sftp wrapper around opendal (#200)
`s3` and `sftp` can be used with `opendal`. Users didn't complain that using `opendal` poses any problems or inconveniences. The current wrapper also have some unfixed bugs, so we remove them. closes rustic-rs/rustic#1045 closes rustic-rs/rustic#1047 --------- Signed-off-by: simonsan <[email protected]>
1 parent 5da72e0 commit fb291dc

File tree

8 files changed

+8
-286
lines changed

8 files changed

+8
-286
lines changed

crates/backend/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ edition = "2021"
3131
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
3232

3333
[features]
34-
default = ["opendal", "s3", "sftp", "rest", "rclone"]
34+
default = ["opendal", "rest", "rclone"]
3535
cli = ["merge", "clap"]
3636
merge = ["dep:merge"]
3737
clap = ["dep:clap"]
38-
s3 = ["opendal"]
3938
opendal = ["dep:opendal", "dep:rayon", "dep:tokio", "tokio/rt-multi-thread"]
4039
rest = ["dep:reqwest", "dep:backoff"]
4140
rclone = ["rest", "dep:rand", "dep:semver"]
42-
# Note: sftp is not yet supported on windows, see below
43-
sftp = ["opendal"]
4441

4542
[dependencies]
4643
# core

crates/backend/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
This library is a part of the [rustic](https://rustic.cli.rs) project and
1515
provides a set of backends for the
1616
[`rustic_core`](https://crates.io/crates/rustic_core) library. It is used to
17-
interact with various storage backends, such as `s3`, `rclone`, `rest`, `sftp`,
18-
and in general `opendal`.
17+
interact with various storage backends, such as `rclone`, `rest`, and in general
18+
`opendal`.
1919

2020
The goal of this library is to provide a unified interface for interacting with
2121
various backends, so that the
@@ -72,12 +72,6 @@ This crate exposes a few features for controlling dependency usage:
7272
- **rest** - Enables support for the `rest` backend. *This feature is enabled by
7373
default*.
7474

75-
- **sftp** - Enables support for the `sftp` backend. Windows is not yet
76-
supported. *This feature is enabled by default*.
77-
78-
- **s3** - Enables support for the `s3` backend. *This feature is enabled by
79-
default*.
80-
8175
## Usage & Examples
8276

8377
Due to being a support crate for

crates/backend/src/choose.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ use crate::{
1313
util::{location_to_type_and_path, BackendLocation},
1414
};
1515

16-
#[cfg(feature = "s3")]
17-
use crate::opendal::s3::S3Backend;
18-
19-
#[cfg(all(unix, feature = "sftp"))]
20-
use crate::opendal::sftp::SftpBackend;
21-
2216
#[cfg(feature = "opendal")]
2317
use crate::opendal::OpenDALBackend;
2418

@@ -156,7 +150,7 @@ pub trait BackendChoice {
156150

157151
/// The supported backend types.
158152
///
159-
/// Currently supported types are "local", "rclone", "rest", "opendal", "s3"
153+
/// Currently supported types are "local", "rclone", "rest", "opendal"
160154
///
161155
/// # Notes
162156
///
@@ -182,16 +176,6 @@ pub enum SupportedBackend {
182176
/// An openDAL backend (general)
183177
#[strum(serialize = "opendal", to_string = "openDAL Backend")]
184178
OpenDAL,
185-
186-
#[cfg(feature = "s3")]
187-
/// An openDAL S3 backend
188-
#[strum(serialize = "s3", to_string = "S3 Backend")]
189-
S3,
190-
191-
#[cfg(all(unix, feature = "sftp"))]
192-
/// An openDAL sftp backend
193-
#[strum(serialize = "sftp", to_string = "sftp Backend")]
194-
Sftp,
195179
}
196180

197181
impl BackendChoice for SupportedBackend {
@@ -210,10 +194,6 @@ impl BackendChoice for SupportedBackend {
210194
Self::Rest => Arc::new(RestBackend::new(location, options)?),
211195
#[cfg(feature = "opendal")]
212196
Self::OpenDAL => Arc::new(OpenDALBackend::new(location, options)?),
213-
#[cfg(feature = "s3")]
214-
Self::S3 => Arc::new(S3Backend::new(location, options)?),
215-
#[cfg(all(unix, feature = "sftp"))]
216-
Self::Sftp => Arc::new(SftpBackend::new(location, options)?),
217197
})
218198
}
219199
}
@@ -233,8 +213,6 @@ mod tests {
233213
#[case("rest", SupportedBackend::Rest)]
234214
#[cfg(feature = "opendal")]
235215
#[case("opendal", SupportedBackend::OpenDAL)]
236-
#[cfg(feature = "s3")]
237-
#[case("s3", SupportedBackend::S3)]
238216
fn test_try_from_is_ok(#[case] input: &str, #[case] expected: SupportedBackend) {
239217
assert_eq!(SupportedBackend::try_from(input).unwrap(), expected);
240218
}

crates/backend/src/lib.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ The following backends are currently supported and can be enabled with features:
1919
- `OpenDALBackend` - Backend for accessing a `OpenDAL` filesystem.
2020
- `RcloneBackend` - Backend for accessing a Rclone filesystem.
2121
- `RestBackend` - Backend for accessing a REST API.
22-
- `SftpBackend` - Backend for accessing a SFTP filesystem.
23-
- `S3Backend` - Backend for accessing a S3 filesystem.
2422
2523
## Usage & Examples
2624
@@ -46,17 +44,12 @@ This crate exposes a few features for controlling dependency usage:
4644
4745
- **opendal** - Enables support for the `opendal` backend. *This feature is
4846
enabled by default*.
47+
4948
- **rclone** - Enables support for the `rclone` backend. *This feature is
5049
enabled by default*.
5150
5251
- **rest** - Enables support for the `rest` backend. *This feature is enabled by
5352
default*.
54-
55-
- **sftp** - Enables support for the `sftp` backend. Windows is not yet
56-
supported. *This feature is enabled by default*.
57-
58-
- **s3** - Enables support for the `s3` backend. *This feature is enabled by
59-
default*.
6053
*/
6154

6255
pub mod choose;
@@ -82,12 +75,6 @@ pub use crate::{
8275
local::LocalBackend,
8376
};
8477

85-
#[cfg(all(unix, feature = "sftp"))]
86-
pub use crate::opendal::sftp::SftpBackend;
87-
88-
#[cfg(feature = "s3")]
89-
pub use crate::opendal::s3::S3Backend;
90-
9178
#[cfg(feature = "opendal")]
9279
pub use crate::opendal::OpenDALBackend;
9380

crates/backend/src/opendal.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/// `OpenDAL` S3 backend for Rustic.
2-
#[cfg(feature = "s3")]
3-
pub mod s3;
4-
/// `OpenDAL` SFTP backend for Rustic.
5-
#[cfg(all(unix, feature = "sftp"))]
6-
pub mod sftp;
7-
1+
/// `OpenDAL` backend for rustic.
82
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::OnceLock};
93

104
use anyhow::Result;
@@ -19,7 +13,7 @@ use tokio::runtime::Runtime;
1913

2014
use rustic_core::{FileType, Id, ReadBackend, WriteBackend, ALL_FILE_TYPES};
2115

22-
mod consts {
16+
mod constants {
2317
/// Default number of retries
2418
pub(super) const DEFAULT_RETRY: usize = 5;
2519
}
@@ -58,7 +52,7 @@ impl OpenDALBackend {
5852
pub fn new(path: impl AsRef<str>, options: HashMap<String, String>) -> Result<Self> {
5953
let max_retries = match options.get("retry").map(String::as_str) {
6054
Some("false" | "off") => 0,
61-
None | Some("default") => consts::DEFAULT_RETRY,
55+
None | Some("default") => constants::DEFAULT_RETRY,
6256
Some(value) => usize::from_str(value)?,
6357
};
6458
let connections = options

crates/backend/src/opendal/s3.rs

Lines changed: 0 additions & 120 deletions
This file was deleted.

crates/backend/src/opendal/sftp.rs

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)