Skip to content

Commit 1d2344c

Browse files
committed
Using libunftp 0.12.0
1 parent 92a01fa commit 1d2344c

File tree

5 files changed

+36
-41
lines changed

5 files changed

+36
-41
lines changed

Cargo.lock

Lines changed: 25 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "unftp"
3-
version = "0.11.0"
3+
version = "0.12.0"
44
authors = [
55
"Agoston Horvath <[email protected]>",
66
"Dávid Kosztka <[email protected]>",
@@ -18,7 +18,7 @@ readme = "README.md"
1818

1919
[dependencies]
2020
async-trait = "0.1.37"
21-
libunftp = {git = "https://github.com/bolcom/libunftp.git", rev = "e4ef636ecf8f5ba31ec083bb15f288f31e05ffb2"}
21+
libunftp = "0.12.0"
2222
redis = "0.9.0"
2323
serde_json = "1.0.57"
2424
chrono = "0.4.6"

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ fn start_ftp_with_storage<S>(
251251
) -> Result<(), String>
252252
where
253253
S: StorageBackend<user::User> + Send + Sync + 'static,
254-
S::File: tokio::io::AsyncRead + Send + Sync,
255254
S::Metadata: Sync + Send,
256255
{
257256
let addr = String::from(arg_matches.value_of(args::BIND_ADDRESS).unwrap());

src/storage.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::fmt::Debug;
66
use std::path::{Path, PathBuf};
77
use std::sync::Arc;
88
use std::time::SystemTime;
9-
use tokio::io::AsyncRead;
109

1110
#[derive(Debug)]
1211
pub enum InnerStorage {
@@ -90,7 +89,6 @@ impl StorageBE {
9089

9190
#[async_trait]
9291
impl StorageBackend<User> for StorageBE {
93-
type File = Box<dyn AsyncRead + Sync + Send + Unpin>;
9492
type Metadata = SBEMeta;
9593

9694
async fn metadata<P: AsRef<Path> + Send + Debug>(&self, user: &Option<User>, path: P) -> Result<Self::Metadata> {
@@ -134,11 +132,11 @@ impl StorageBackend<User> for StorageBE {
134132
user: &Option<User>,
135133
path: P,
136134
start_pos: u64,
137-
) -> Result<Self::File> {
135+
) -> Result<Box<dyn tokio::io::AsyncRead + Send + Sync + Unpin>> {
138136
slog::info!(self.log(user, &path), "Client requested to retrieve a file");
139137
match &self.inner {
140-
InnerStorage::Cloud(i) => i.get(user, path, start_pos).await.map(castc),
141-
InnerStorage::File(i) => i.get(user, path, start_pos).await.map(castf),
138+
InnerStorage::Cloud(i) => i.get(user, path, start_pos).await,
139+
InnerStorage::File(i) => i.get(user, path, start_pos).await,
142140
}
143141
}
144142

@@ -197,11 +195,3 @@ impl StorageBackend<User> for StorageBE {
197195
}
198196
}
199197
}
200-
201-
fn castf(f: tokio::io::BufReader<tokio::fs::File>) -> Box<dyn AsyncRead + Sync + Send + Unpin> {
202-
Box::new(f)
203-
}
204-
205-
fn castc(f: libunftp::storage::cloud_storage::object::Object) -> Box<dyn AsyncRead + Sync + Send + Unpin> {
206-
Box::new(f)
207-
}

src/user.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use async_trait::async_trait;
2-
use libunftp::auth::{AuthenticationError, DefaultUser, UserDetail};
2+
use libunftp::auth::{DefaultUser, UserDetail};
33
use std::fmt::Formatter;
44

55
#[derive(Debug, PartialEq)]
@@ -49,7 +49,11 @@ impl LookupAuthenticator {
4949

5050
#[async_trait]
5151
impl libunftp::auth::Authenticator<User> for LookupAuthenticator {
52-
async fn authenticate(&self, username: &str, password: &str) -> Result<User, AuthenticationError> {
52+
async fn authenticate(
53+
&self,
54+
username: &str,
55+
password: &str,
56+
) -> Result<User, Box<dyn std::error::Error + Send + Sync>> {
5357
self.inner.authenticate(username, password).await?;
5458
// TODO: User successfully authenticated, now lookup user details from repository e.g. PostgreSql
5559
Ok(User {

0 commit comments

Comments
 (0)