diff --git a/CHANGELOG.md b/CHANGELOG.md index 14156b2..a6c6d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog - [Changelog](#changelog) + - [0.3.1](#031) - [0.3.0](#030) - [0.2.1](#021) - [0.2.0](#020) @@ -13,6 +14,12 @@ --- +## 0.3.1 + +Released on 09/07/2024 + +- Fix: parse special permissions `StT` in ls output + ## 0.3.0 Released on 09/07/2024 diff --git a/Cargo.toml b/Cargo.toml index 3627293..6c8b92f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,13 +11,12 @@ license = "MIT" name = "remotefs-ssh" readme = "README.md" repository = "https://github.com/veeso/remotefs-rs-ssh" -version = "0.3.0" +version = "0.3.1" [dependencies] chrono = "^0.4" -lazy_static = "^1.4" +lazy-regex = "3" log = "^0.4" -regex = "^1.7" remotefs = "^0.2" ssh2-config = "^0.2" ssh2 = "^0.9" diff --git a/README.md b/README.md index 7e9cdcf..1f88374 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

~ Remotefs SSH client ~

Developed by @veeso

-

Current version: 0.3.0 (09/07/2024)

+

Current version: 0.3.1 (09/07/2024)

+static LS_RE: Lazy = lazy_regex!( + r#"^([\-ld])([\-rwxsStT]{9})\s+(\d+)\s+(.+)\s+(.+)\s+(\d+)\s+(\w{3}\s+\d{1,2}\s+(?:\d{1,2}:\d{1,2}|\d{4}))\s+(.+)$"# +); + /// SCP "filesystem" client pub struct ScpFs { session: Option, @@ -52,15 +57,9 @@ impl ScpFs { } } - /// ### parse_ls_output - /// /// Parse a line of `ls -l` output and tokenize the output into a `FsFile` fn parse_ls_output(&self, path: &Path, line: &str) -> Result { // Prepare list regex - // NOTE: about this damn regex - lazy_static! { - static ref LS_RE: Regex = Regex::new(r#"^([\-ld])([\-rwxs]{9})\s+(\d+)\s+(.+)\s+(.+)\s+(\d+)\s+(\w{3}\s+\d{1,2}\s+(?:\d{1,2}:\d{1,2}|\d{4}))\s+(.+)$"#).unwrap(); - } trace!("Parsing LS line: '{}'", line); // Apply regex to result match LS_RE.captures(line) { @@ -1385,6 +1384,37 @@ mod test { ); } + #[test] + fn test_should_parse_special_permissions_ls_output() { + let client = ScpFs::new(SshOpts::new("localhost")); + assert!(client + .parse_ls_output( + Path::new("/tmp"), + "-rw-rwSrw- 1 manufact manufact 241813 Apr 22 09:31 L9800.SPF", + ) + .is_ok()); + assert!(client + .parse_ls_output( + Path::new("/tmp"), + "-rw-rwsrw- 1 manufact manufact 241813 Apr 22 09:31 L9800.SPF", + ) + .is_ok()); + + assert!(client + .parse_ls_output( + Path::new("/tmp"), + "-rw-rwtrw- 1 manufact manufact 241813 Apr 22 09:31 L9800.SPF", + ) + .is_ok()); + + assert!(client + .parse_ls_output( + Path::new("/tmp"), + "-rw-rwTrw- 1 manufact manufact 241813 Apr 22 09:31 L9800.SPF", + ) + .is_ok()); + } + #[test] fn should_return_errors_on_uninitialized_client() { let mut client = ScpFs::new(SshOpts::new("localhost"));