formatting and changelog #221

This commit is contained in:
sagie gur ari 2022-02-13 15:32:46 +00:00
parent cfe2d73a74
commit c346bcd22b
3 changed files with 14 additions and 20 deletions

View file

@ -1,5 +1,9 @@
## CHANGELOG
### v0.8.11
* Enhancement: New get_file_size/filesize command #222
### v0.8.10 (2021-12-10)
* New SDK and cli tls feature to enable usage without tls support (by default enabled)

View file

@ -9,11 +9,7 @@ fn common_functions() {
#[test]
fn run_no_path_provided() {
test::run_script_and_error(
vec![create("")],
"out = get_file_size",
"out"
);
test::run_script_and_error(vec![create("")], "out = get_file_size", "out");
}
#[test]
@ -27,18 +23,10 @@ fn run_file() {
#[test]
fn run_directory() {
test::run_script_and_error(
vec![create("")],
"out = get_file_size ./src",
"out",
);
test::run_script_and_error(vec![create("")], "out = get_file_size ./src", "out");
}
#[test]
fn run_not_found() {
test::run_script_and_error(
vec![create("")],
"out = get_file_size ./badpath",
"out",
);
test::run_script_and_error(vec![create("")], "out = get_file_size ./badpath", "out");
}

View file

@ -57,11 +57,13 @@ pub(crate) fn get_last_modified_time(path: &str) -> Result<u128, String> {
pub(crate) fn get_file_size(path: &str) -> Result<u64, String> {
match std::fs::metadata(path) {
Ok(metadata) => if metadata.is_file() {
Ok(metadata.len())
} else {
Err("The provided path is not a file.".to_string())
},
Ok(metadata) => {
if metadata.is_file() {
Ok(metadata.len())
} else {
Err("The provided path is not a file.".to_string())
}
}
Err(_error) => Err("Unable to extract metadata for path.".to_string()),
}
}