made it work from windows and fixed receiver
This commit is contained in:
parent
6ca31b4cf6
commit
fe25daeaca
3 changed files with 43 additions and 211 deletions
|
|
@ -38,11 +38,13 @@ local-ip-address = "0.6.1"
|
|||
axum-extra = { version = "0.9.3", features = ["typed-header"] }
|
||||
headers = "0.4"
|
||||
tower = { version = "0.4", features = ["util"] }
|
||||
reqwest = { version = "0.12.4", features = ["blocking", "json"] }
|
||||
reqwest = { version = "0.12.4", default-features = false, features = [
|
||||
"blocking",
|
||||
"json",
|
||||
"rustls-tls",
|
||||
] }
|
||||
hex = "0.4.3"
|
||||
anyhow = "1.0.83"
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
openssl-sys = { version = "0.9.102", features = ["vendored"] }
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.12.4"
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ const DESTINATION: u8 = 0;
|
|||
const NONCE_SIZE: usize = 12;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
const FILE_PATH_PREFIX: &str = "/storage/emulated/0/Download";
|
||||
const FILE_PATH_PREFIX: &str = "/storage/emulated/0/Documents";
|
||||
|
||||
struct File {
|
||||
name: String,
|
||||
|
|
@ -74,10 +74,17 @@ fn on_list(context: &mut Context, list: ListPacket) -> Status {
|
|||
return Status::Err("Invalid list packet: no shared key established".into());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
let mut prefix = std::path::PathBuf::from(std::env::current_exe().unwrap());
|
||||
// #[cfg(target_os = "android")]
|
||||
// prefix.pop();
|
||||
// #[cfg(target_os = "android")]
|
||||
// println!("prefix: {:?}", prefix);
|
||||
for entry in list.entries {
|
||||
let path = sanitize_filename::sanitize(entry.name.clone());
|
||||
#[cfg(target_os = "android")]
|
||||
let file_path = format!("{}/{}", FILE_PATH_PREFIX, path);
|
||||
// let file_path = format!("{}/{}", prefix.display(), path);
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
if Path::new(&file_path).exists() {
|
||||
|
|
@ -97,7 +104,7 @@ fn on_list(context: &mut Context, list: ListPacket) -> Status {
|
|||
if Path::new(&path).exists() {
|
||||
return Status::Err(format!("The file '{}' already exists.", path));
|
||||
}
|
||||
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
let handle = match fs::File::create(&path) {
|
||||
Ok(handle) => handle,
|
||||
|
|
@ -482,4 +489,4 @@ mod tests {
|
|||
Status::Err("Invalid chunk packet: no shared key established".into())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue