Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete throw CrossesDevices error in some cases #85

Closed
oluceps opened this issue Oct 5, 2023 · 2 comments
Closed

delete throw CrossesDevices error in some cases #85

oluceps opened this issue Oct 5, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@oluceps
Copy link

oluceps commented Oct 5, 2023

Minimal reproduce

// src/main.rs
use std::path::PathBuf;
use trash::delete;
fn main() {
    delete(PathBuf::from("./test")).unwrap();
}
> df -h
Filesystem      Size  Used Avail Use% Mounted on
none            2.0G  218M  1.8G  11% /
/dev/nvme0n1p2  461G  296G  155G  66% /var
/dev/nvme0n1p2  461G  296G  155G  66% /persist
/dev/nvme0n1p2  461G  296G  155G  66% /nix
tmpfs           3.8G   16M  3.7G   1% /run
devtmpfs        760M     0  760M   0% /dev
tmpfs           7.5G  287M  7.2G   4% /dev/shm
tmpfs           7.5G  340K  7.5G   1% /run/wrappers
efivarfs        148K   61K   83K  43% /sys/firmware/efi/efivars
tmpfs            12G  3.7M   12G   1% /tmp
/dev/nvme0n1p1  500M  315M  186M  63% /efi
tmpfs           1.5G  168K  1.5G   1% /run/user/1000
> mount | rg home
# ...
/dev/nvme0n1p2 on /home/elen/.local type btrfs (rw,noatime,compress-force=zstd:3,ssd,discard=async,space_cache=v2,subvolid=256,subvol=/persist,x-gvfs-hide)
> ./test-trash
The home topdir is "/"
Deleting "/home/elen/test"
The topdir of this file is "/"
The topdir was identical to the home topdir, so moving to the home trash.
mv "/home/elen/test" "/home/elen/.local/share/Trash/files/test.118777"
thread 'main' panicked at src/main.rs:6:37:
called `Result::unwrap()` on an `Err` value: FileSystem { path: "/home/elen/.local/share/Trash/files/test.118777", kind: CrossesDevices }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Possible issue

src/freedesktop.rs:507 trying to rename across devices. Since ~/.local and ~ not in identical device.

trash-rs/src/freedesktop.rs

Lines 494 to 515 in 0789b23

fn move_items_no_replace(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<(), std::io::Error> {
let src = src.as_ref();
let dst = dst.as_ref();
try_creating_placeholders(src, dst)?;
// All placeholders are in place. LET'S OVERWRITE
execute_src_to_dst_operation(src, dst, &|_| Ok(()), &|src, dst| {
if let Some(parent) = dst.parent() {
if let Err(err) = std::fs::create_dir_all(parent) {
warn!("Failed to create destination directory. It probably already exists. {:?}", err);
}
}
std::fs::rename(src, dst)
})?;
// Once everything is moved, lets recursively remove the directory
if src.is_dir() {
std::fs::remove_dir_all(src)?;
}
Ok(())
}

@Byron Byron added bug Something isn't working help wanted Extra attention is needed labels Oct 5, 2023
@oluceps
Copy link
Author

oluceps commented Oct 5, 2023

Seems already had an issue there #57

@Byron
Copy link
Owner

Byron commented Oct 5, 2023

Thanks! Closing as duplicate to keep communication in one place.

@Byron Byron closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants