-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Don't trash files on different device to home dir on Linux #3304
Conversation
I've asked on send2trash about having a more specific exception type that we could catch: arsenetar/send2trash#20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
# files on the same partition as the home directory. | ||
file_dev = os.stat(os_path).st_dev | ||
home_dev = os.stat(os.path.expanduser('~')).st_dev | ||
return file_dev == home_dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this test doesn't do what you'd hope on GPFS (under Linux). If the directories are part of different filesets, you'll still get an EXDEV
if you try to rename a file/dir from one to the other.
_check_trash() was added (in jupyter#3304) because TrashPermissionError didn't exist, yet. Now that it does, we can use it, and stop guessing what will cause a permission problem. Closes: jupyter#3374
This is a bit of a crude check, but I imagine that most users will be working either in their home directory, or on the same device, so it's not worth trying to do a more complex check. I'm going to ask for better exceptions from send2trash so we can distinguish these cases from others.
Closes gh-3249