diff --git a/Cargo.lock b/Cargo.lock index 30d63f1..1a30207 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,11 +19,26 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.5.3" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ - "memchr 0.1.11", + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", ] [[package]] @@ -116,6 +131,12 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + [[package]] name = "camino" version = "1.1.6" @@ -144,10 +165,12 @@ dependencies = [ "colored", "either", "enum_dispatch", - "ftp", + "env_logger", + "log", "rustc_version", "serde", "serde_json", + "suppaftp", "tee", "tempfile", "walkdir", @@ -184,12 +207,14 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.2.25" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9213f7cd7c27e95c2b57c49f0e69b1ea65b27138da84a170133fd21b07659c00" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ - "num", - "time", + "android-tzdata", + "iana-time-zone", + "num-traits", + "windows-targets", ] [[package]] @@ -245,10 +270,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2674ec482fbc38012cf31e6c42ba0177b431a0cb6f15fe40efa5aab1bda516f6" dependencies = [ "is-terminal", - "lazy_static 1.4.0", + "lazy_static", "windows-sys", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + [[package]] name = "either" version = "1.9.0" @@ -267,6 +298,19 @@ dependencies = [ "syn", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "errno" version = "0.3.4" @@ -294,17 +338,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" -[[package]] -name = "ftp" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "542951aad0071952c27409e3bd7cb62d1a3ad419c4e7314106bf994e0083ad5d" -dependencies = [ - "chrono", - "lazy_static 0.1.16", - "regex", -] - [[package]] name = "gimli" version = "0.28.0" @@ -323,6 +356,35 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + [[package]] name = "is-terminal" version = "0.4.9" @@ -341,20 +403,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "js-sys" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ - "winapi 0.2.8", - "winapi-build", + "wasm-bindgen", ] [[package]] -name = "lazy_static" -version = "0.1.16" +name = "lazy-regex" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" +checksum = "e723bd417b2df60a0f6a2b6825f297ea04b245d4ba52b5a22cb679bdf58b05fa" +dependencies = [ + "lazy-regex-proc_macros", + "once_cell", + "regex", +] + +[[package]] +name = "lazy-regex-proc_macros" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0a1d9139f0ee2e862e08a9c5d0ba0470f2aa21cd1e1aa1b1562f83116c725f" +dependencies = [ + "proc-macro2", + "quote", + "regex", + "syn", +] [[package]] name = "lazy_static" @@ -375,13 +453,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45786cec4d5e54a224b15cb9f06751883103a27c19c93eda09b0b4f5f08fefac" [[package]] -name = "memchr" -version = "0.1.11" +name = "log" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" -dependencies = [ - "libc", -] +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" @@ -398,38 +473,6 @@ dependencies = [ "adler", ] -[[package]] -name = "num" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" -dependencies = [ - "num-integer", - "num-iter", - "num-traits", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.17" @@ -445,7 +488,7 @@ version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ - "memchr 2.6.4", + "memchr", ] [[package]] @@ -483,22 +526,32 @@ dependencies = [ [[package]] name = "regex" -version = "0.1.80" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", - "memchr 0.1.11", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", - "thread_local", - "utf8-ranges", ] [[package]] name = "regex-syntax" -version = "0.3.9" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustc-demangle" @@ -589,6 +642,18 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "suppaftp" +version = "5.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bff3c71bf1c1b8ffc029665ce9213b4ea6a06cdcc8ca884addf95584d903281" +dependencies = [ + "chrono", + "lazy-regex", + "log", + "thiserror", +] + [[package]] name = "syn" version = "2.0.38" @@ -619,6 +684,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "termcolor" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.49" @@ -639,48 +713,12 @@ dependencies = [ "syn", ] -[[package]] -name = "thread-id" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" -dependencies = [ - "kernel32-sys", - "libc", -] - -[[package]] -name = "thread_local" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" -dependencies = [ - "thread-id", -] - -[[package]] -name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi", - "winapi 0.3.9", -] - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "utf8-ranges" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" - [[package]] name = "utf8parse" version = "0.2.1" @@ -698,16 +736,58 @@ dependencies = [ ] [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "wasm-bindgen" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] [[package]] -name = "winapi" -version = "0.2.8" +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "winapi" @@ -719,12 +799,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -737,7 +811,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -746,6 +820,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 0032679..85c9298 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,10 +18,12 @@ clap = { version = "4.4.2", features = ["derive", "env"] } colored = "2.0.4" either = "1.9.0" enum_dispatch = "0.3.12" -ftp = "3.0.1" +env_logger = "0.10.0" +log = "0.4.20" rustc_version = "0.4.0" serde = { version = "1.0.188", features = ["derive"] } serde_json = "1.0.105" +suppaftp = {version = "5.2.1", features = ["no-log"] } tee = "0.1.0" tempfile = "3.8.0" walkdir = "2.4.0" diff --git a/src/commands/build.rs b/src/commands/build.rs index 090401b..d85fbbb 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -501,7 +501,7 @@ impl<'a> BuildContext<'a> { } let src = File::open(src).context("Unable to open source file")?; - ftp.put(dest, &mut BufReader::new(src)) + ftp.put_file(dest, &mut BufReader::new(src)) .context("Failed to upload file")?; } diff --git a/src/commands/coredump.rs b/src/commands/coredump.rs index 6cd28e5..29372bf 100644 --- a/src/commands/coredump.rs +++ b/src/commands/coredump.rs @@ -3,10 +3,10 @@ use std::{ process::{Command, Stdio}, }; -use ::ftp::FtpError; use anyhow::{bail, Context}; use clap::{Args, Subcommand}; use colored::Colorize; +use suppaftp::FtpError; use tempfile::NamedTempFile; use super::{ConnectionArgs, Executor}; @@ -63,7 +63,9 @@ impl Executor for Coredump { if verbose > 0 { println!("{} {coredump}", "Downloading file:".blue()) } - let mut reader = ftp.get(coredump).context("Unable to download coredump")?; + let mut reader = ftp + .retr_as_buffer(coredump) + .context("Unable to download coredump")?; let mut tmp_file = NamedTempFile::new().context("Unable to create temporary file")?; @@ -138,7 +140,8 @@ impl Executor for Coredump { match ftp.rm(file) { Ok(_) => {} - Err(FtpError::InvalidResponse(e)) if e.contains("226 File deleted") => {} + Err(FtpError::UnexpectedResponse(e)) + if String::from_utf8_lossy(&e.body).contains("226 File deleted") => {} Err(e) => return Err(e).context("Unable to delete file"), } } diff --git a/src/commands/upload.rs b/src/commands/upload.rs index 6e439e9..6389bfa 100644 --- a/src/commands/upload.rs +++ b/src/commands/upload.rs @@ -1,12 +1,13 @@ use std::{fs::File, io::BufReader, path::Path}; -use crate::ftp; -use ::ftp::FtpError; use anyhow::{bail, Context}; use clap::Args; use colored::Colorize; +use suppaftp::FtpError; use walkdir::WalkDir; +use crate::ftp; + use super::{ConnectionArgs, Executor}; #[derive(Args, Debug)] @@ -53,7 +54,7 @@ impl Executor for Upload { ); } - ftp.put( + ftp.put_file( &destination, &mut BufReader::new(File::open(source).context("Unable to open source file")?), ) @@ -79,7 +80,7 @@ impl Executor for Upload { ); } - ftp.put( + ftp.put_file( &destination, &mut BufReader::new( File::open(source_path).context("Unable to open source file")?, @@ -99,8 +100,9 @@ impl Executor for Upload { } match ftp.mkdir(&destination) { Ok(_) => {} - Err(FtpError::InvalidResponse(e)) - if e.starts_with("226 Directory created.") => {} + Err(FtpError::UnexpectedResponse(e)) + if String::from_utf8_lossy(&e.body) + .starts_with("226 Directory created.") => {} Err(e) => { if verbose > 1 { eprintln!( diff --git a/src/ftp.rs b/src/ftp.rs index 514d8b8..492b276 100644 --- a/src/ftp.rs +++ b/src/ftp.rs @@ -2,7 +2,7 @@ use std::ops::Deref; use anyhow::Context; use colored::Colorize; -use ftp::FtpStream; +use suppaftp::FtpStream; use crate::commands::ConnectionArgs;