Skip to content

Commit

Permalink
feat(backend)!: remove s3 and sftp wrapper around opendal
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <[email protected]>
  • Loading branch information
simonsan committed Mar 13, 2024
1 parent 6c6240c commit 8a0714b
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 257 deletions.
5 changes: 1 addition & 4 deletions crates/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["opendal", "s3", "sftp", "rest", "rclone"]
default = ["opendal", "rest", "rclone"]
cli = ["merge", "clap"]
merge = ["dep:merge"]
clap = ["dep:clap"]
s3 = ["opendal"]
opendal = ["dep:opendal", "dep:rayon", "dep:tokio", "tokio/rt-multi-thread"]
rest = ["dep:reqwest", "dep:backoff"]
rclone = ["rest", "dep:rand", "dep:semver"]
# Note: sftp is not yet supported on windows, see below
sftp = ["opendal"]

[dependencies]
# core
Expand Down
22 changes: 0 additions & 22 deletions crates/backend/src/choose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ use crate::{
util::{location_to_type_and_path, BackendLocation},
};

#[cfg(feature = "s3")]
use crate::opendal::s3::S3Backend;

#[cfg(all(unix, feature = "sftp"))]
use crate::opendal::sftp::SftpBackend;

#[cfg(feature = "opendal")]
use crate::opendal::OpenDALBackend;

Expand Down Expand Up @@ -182,16 +176,6 @@ pub enum SupportedBackend {
/// An openDAL backend (general)
#[strum(serialize = "opendal", to_string = "openDAL Backend")]
OpenDAL,

#[cfg(feature = "s3")]
/// An openDAL S3 backend
#[strum(serialize = "s3", to_string = "S3 Backend")]
S3,

#[cfg(all(unix, feature = "sftp"))]
/// An openDAL sftp backend
#[strum(serialize = "sftp", to_string = "sftp Backend")]
Sftp,
}

impl BackendChoice for SupportedBackend {
Expand All @@ -210,10 +194,6 @@ impl BackendChoice for SupportedBackend {
Self::Rest => Arc::new(RestBackend::new(location, options)?),
#[cfg(feature = "opendal")]
Self::OpenDAL => Arc::new(OpenDALBackend::new(location, options)?),
#[cfg(feature = "s3")]
Self::S3 => Arc::new(S3Backend::new(location, options)?),
#[cfg(all(unix, feature = "sftp"))]
Self::Sftp => Arc::new(SftpBackend::new(location, options)?),
})
}
}
Expand All @@ -233,8 +213,6 @@ mod tests {
#[case("rest", SupportedBackend::Rest)]
#[cfg(feature = "opendal")]
#[case("opendal", SupportedBackend::OpenDAL)]
#[cfg(feature = "s3")]
#[case("s3", SupportedBackend::S3)]
fn test_try_from_is_ok(#[case] input: &str, #[case] expected: SupportedBackend) {
assert_eq!(SupportedBackend::try_from(input).unwrap(), expected);
}
Expand Down
12 changes: 3 additions & 9 deletions crates/backend/src/opendal.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/// `OpenDAL` S3 backend for Rustic.
#[cfg(feature = "s3")]
pub mod s3;
/// `OpenDAL` SFTP backend for Rustic.
#[cfg(all(unix, feature = "sftp"))]
pub mod sftp;

/// `OpenDAL` backend for rustic.
use std::{collections::HashMap, path::PathBuf, str::FromStr, sync::OnceLock};

use anyhow::Result;
Expand All @@ -19,7 +13,7 @@ use tokio::runtime::Runtime;

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

mod consts {
mod constants {
/// Default number of retries
pub(super) const DEFAULT_RETRY: usize = 5;
}
Expand Down Expand Up @@ -58,7 +52,7 @@ impl OpenDALBackend {
pub fn new(path: impl AsRef<str>, options: HashMap<String, String>) -> Result<Self> {
let max_retries = match options.get("retry").map(String::as_str) {
Some("false" | "off") => 0,
None | Some("default") => consts::DEFAULT_RETRY,
None | Some("default") => constants::DEFAULT_RETRY,
Some(value) => usize::from_str(value)?,
};
let connections = options
Expand Down
120 changes: 0 additions & 120 deletions crates/backend/src/opendal/s3.rs

This file was deleted.

102 changes: 0 additions & 102 deletions crates/backend/src/opendal/sftp.rs

This file was deleted.

0 comments on commit 8a0714b

Please sign in to comment.