mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: use easier method of determining if path is subdirectory of itself
This commit is contained in:
parent
ae13c29488
commit
0c18664419
1 changed files with 6 additions and 12 deletions
|
|
@ -135,18 +135,12 @@ impl File {
|
|||
|
||||
pub async fn paste(&self, mut task: FileOpPaste) -> Result<()> {
|
||||
// Prevent pasting of a directory into itself
|
||||
if task.from.is_dir() {
|
||||
let mut parent = task.to.parent_url();
|
||||
while let Some(p) = parent {
|
||||
if task.from == p {
|
||||
debug!(
|
||||
"file_paste: cannot paste directory into itself, skipping {:?} -> {:?}",
|
||||
task.from, task.to
|
||||
);
|
||||
return self.succ(task.id);
|
||||
}
|
||||
parent = p.parent_url();
|
||||
}
|
||||
if task.from.is_dir() && task.to.as_path().starts_with(task.from.as_path()) {
|
||||
debug!(
|
||||
"file_paste: cannot paste directory into itself, skipping {:?} -> {:?}",
|
||||
task.from, task.to
|
||||
);
|
||||
return self.succ(task.id);
|
||||
}
|
||||
|
||||
if task.cut {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue