chore(rust): update lockfile and format sources
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+19
-11
@@ -1,15 +1,11 @@
|
||||
use crate::cache::{create_authenticated_conn, load_cache_with_token_refresh};
|
||||
use crate::commands::shared::{
|
||||
find_file_by_name, find_folder, find_lab_in_cache,
|
||||
find_subfolder_by_name, nfc, parse_remote_path,
|
||||
find_file_by_name, find_folder, find_lab_in_cache, find_subfolder_by_name, nfc,
|
||||
parse_remote_path,
|
||||
};
|
||||
use anyhow::{bail};
|
||||
use anyhow::bail;
|
||||
|
||||
pub async fn cp(
|
||||
src_path: &str,
|
||||
dest_path: &str,
|
||||
recursive: bool,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
pub async fn cp(src_path: &str, dest_path: &str, recursive: bool) -> Result<(), anyhow::Error> {
|
||||
let (s_remote, s_lab, s_path) = parse_remote_path(src_path)?;
|
||||
let dest_ends_with_slash = dest_path.ends_with('/');
|
||||
let (d_remote, d_lab, d_path) = parse_remote_path(dest_path)?;
|
||||
@@ -51,7 +47,11 @@ pub async fn cp(
|
||||
bail!("File `{}` already exists.", d_basename);
|
||||
}
|
||||
if find_subfolder_by_name(&d_parent_folder.sub_folders, &d_basename).is_some() {
|
||||
bail!("Cannot overwrite non-folder `{}` with folder `{}`.", d_basename, d_path);
|
||||
bail!(
|
||||
"Cannot overwrite non-folder `{}` with folder `{}`.",
|
||||
d_basename,
|
||||
d_path
|
||||
);
|
||||
}
|
||||
// No-op if source and destination are identical
|
||||
if s_parent_folder.id == d_parent_folder.id && d_basename == s_basename {
|
||||
@@ -81,13 +81,21 @@ pub async fn cp(
|
||||
}
|
||||
let src_folder_id = src_folder.id.clone();
|
||||
if find_file_by_name(&d_parent_files, &d_basename).is_some() {
|
||||
bail!("Cannot overwrite non-folder `{}` with folder `{}`.", d_basename, s_path);
|
||||
bail!(
|
||||
"Cannot overwrite non-folder `{}` with folder `{}`.",
|
||||
d_basename,
|
||||
s_path
|
||||
);
|
||||
}
|
||||
if let Some(d_folder) = find_subfolder_by_name(&d_parent_folder.sub_folders, &d_basename) {
|
||||
if d_folder.id == src_folder_id {
|
||||
bail!("`{}` and `{}` are the same folder.", s_path, s_path);
|
||||
}
|
||||
bail!("Cannot move `{}` to `{}`: Folder not empty.", s_path, d_path);
|
||||
bail!(
|
||||
"Cannot move `{}` to `{}`: Folder not empty.",
|
||||
s_path,
|
||||
d_path
|
||||
);
|
||||
}
|
||||
// No-op if source and destination are identical
|
||||
if s_parent_folder.id == d_parent_folder.id && s_basename == d_basename {
|
||||
|
||||
Reference in New Issue
Block a user