From 779ece05f83b162eddfa3df45b16ca46f4c02b7c Mon Sep 17 00:00:00 2001 From: omikuji Date: Tue, 19 Feb 2019 16:19:37 +0900 Subject: [PATCH] fix path considering the directory hierarchy --- src/server.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index 72c346e..1eb3051 100644 --- a/src/server.rs +++ b/src/server.rs @@ -302,6 +302,7 @@ impl Session Some(ExternalCommand(Command::Retr{path})) => { let tx_sending = tx.clone(); let tx_error = tx.clone(); + let path = cwd.join(path); tokio::spawn( storage.get(path) .map_err(|_| std::io::Error::new(ErrorKind::Other, "Failed to get file")) @@ -335,6 +336,7 @@ impl Session Some(ExternalCommand(Command::Stor{path})) => { let tx_ok = tx.clone(); let tx_error = tx.clone(); + let path = cwd.join(path); tokio::spawn( storage.put(socket, path) .map_err(|_| std::io::Error::new(ErrorKind::Other, "Failed to put file")) @@ -860,6 +862,7 @@ impl Server let storage = Arc::clone(&session.storage); let tx_success = tx.clone(); let tx_fail = tx.clone(); + let path = &session.cwd.join(path); tokio::spawn( storage.del(path) .map_err(|_| std::io::Error::new(ErrorKind::Other, "Failed to delete file")) @@ -889,8 +892,9 @@ impl Server let storage = Arc::clone(&session.storage); let tx_success = tx.clone(); let tx_fail = tx.clone(); + let mkd_path = &session.cwd.join(&path); tokio::spawn( - storage.mkd(&path) + storage.mkd(&mkd_path) .map_err(|_| std::io::Error::new(ErrorKind::Other, "Failed to create directory")) .and_then(|_| { tx_success.send(InternalMsg::MkdirSuccess(path))