Skip to content

Commit

Permalink
small folder support changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chanderlud committed Dec 5, 2023
1 parent 9a15f4f commit 63efb50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ impl FileLocation {
self.host.is_none() || (self.host.is_some() && self.file_path.exists())
}

fn is_dir(&self) -> bool {
self.file_path.is_dir()
}

async fn file_size(&self) -> io::Result<u64> {
let metadata = tokio::fs::metadata(&self.file_path).await?;
Ok(metadata.len())
Expand Down
1 change: 1 addition & 0 deletions src/receiver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub(crate) async fn main(
mut control_stream: TcpStream,
remote_addr: IpAddr,
) -> Result<()> {
// TODO what if the source is a directory?
if options.destination.file_path.is_dir() {
info!("destination is a folder, reformatting path with target file");

Expand Down
11 changes: 11 additions & 0 deletions src/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ pub(crate) async fn main(
) -> Result<()> {
info!("sending {} -> {}", options.source, options.destination);

if options.source.is_dir() {
for entry in options.source.file_path.read_dir()? {
if let Ok(entry) = entry {
println!("{:?}", entry);
entry.path().is_dir(); // lol
}
}

return Ok(());
}

let file_size = options.source.file_size().await?;
stats.total_data.store(file_size as usize, Relaxed);
// send the file size to the remote client
Expand Down

0 comments on commit 63efb50

Please sign in to comment.