mirror of
https://github.com/sagiegurari/duckscript
synced 2024-09-06 00:34:07 +00:00
formatting and changelog #221
This commit is contained in:
parent
cfe2d73a74
commit
c346bcd22b
|
@ -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)
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue