Skip to content

Commit

Permalink
fix(oli): Fix cp -r command returns invalid path error (#3687)
Browse files Browse the repository at this point in the history
Fix cp -r command returns invalid path error

Signed-off-by: Kebe <[email protected]>
  • Loading branch information
kebe7jun authored Nov 30, 2023
1 parent 146e960 commit 075f4d6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/oli/src/commands/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ pub async fn main(args: &ArgMatches) -> Result<()> {

let dst_root = Path::new(&dst_path);
let mut ds = src_op.lister_with(&src_path).recursive(true).await?;
let prefix = src_path.strip_prefix('/').unwrap_or(src_path.as_str());
while let Some(de) = ds.try_next().await? {
let meta = de.metadata();
if meta.mode().is_dir() {
continue;
}

let fp = de.path().strip_prefix(&src_path).expect("invalid path");
let depath = de.path();
let fp = depath
.strip_prefix('/')
.unwrap_or(depath)
.strip_prefix(prefix)
.expect("invalid path");
let reader = src_op.reader(de.path()).await?;
let buf_reader = futures::io::BufReader::with_capacity(8 * 1024 * 1024, reader);

Expand Down

0 comments on commit 075f4d6

Please sign in to comment.