mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 20:15:27 +00:00
Document unwrap safety
This commit is contained in:
parent
4fc49b63cc
commit
a87b89073e
@ -538,9 +538,10 @@ fn smart_unpack(
|
|||||||
let root_contains_only_one_element = fs::read_dir(&temp_dir_path)?.count() == 1;
|
let root_contains_only_one_element = fs::read_dir(&temp_dir_path)?.count() == 1;
|
||||||
if root_contains_only_one_element {
|
if root_contains_only_one_element {
|
||||||
// Only one file in the root directory, so we can just move it to the output directory
|
// Only one file in the root directory, so we can just move it to the output directory
|
||||||
let file = fs::read_dir(&temp_dir_path)?.next().unwrap().unwrap();
|
let file = fs::read_dir(&temp_dir_path)?.next().expect("item exists")?;
|
||||||
let file_path = file.path();
|
let file_path = file.path();
|
||||||
let file_name = file_path.file_name().unwrap().to_str().unwrap();
|
let file_name =
|
||||||
|
file_path.file_name().expect("Should be safe because paths in archives should not end with '..'");
|
||||||
let correct_path = output_dir.join(file_name);
|
let correct_path = output_dir.join(file_name);
|
||||||
// One case to handle tough is we need to check if a file with the same name already exists
|
// One case to handle tough is we need to check if a file with the same name already exists
|
||||||
if !utils::clear_path(&correct_path, question_policy)? {
|
if !utils::clear_path(&correct_path, question_policy)? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user