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<()> {
|
pub async fn paste(&self, mut task: FileOpPaste) -> Result<()> {
|
||||||
// Prevent pasting of a directory into itself
|
// Prevent pasting of a directory into itself
|
||||||
if task.from.is_dir() {
|
if task.from.is_dir() && task.to.as_path().starts_with(task.from.as_path()) {
|
||||||
let mut parent = task.to.parent_url();
|
debug!(
|
||||||
while let Some(p) = parent {
|
"file_paste: cannot paste directory into itself, skipping {:?} -> {:?}",
|
||||||
if task.from == p {
|
task.from, task.to
|
||||||
debug!(
|
);
|
||||||
"file_paste: cannot paste directory into itself, skipping {:?} -> {:?}",
|
return self.succ(task.id);
|
||||||
task.from, task.to
|
|
||||||
);
|
|
||||||
return self.succ(task.id);
|
|
||||||
}
|
|
||||||
parent = p.parent_url();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if task.cut {
|
if task.cut {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue