sindresorhus / trash

Move files and directories to the trash
MIT License
2.57k stars 78 forks source link

fix: ensure “first one wins” on mountPointMap on identical devId; fil… #124

Closed nocke closed 1 year ago

nocke commented 1 year ago

Original bug encountered (Ubuntu-MATE 22.04)

Error: ENOENT: no such file or directory, mkdir '/var/snap/firefox/common/host-hunspell/.Trash-1000'

What became clear after some investigation was, that all my files (under /common/... and /depot/... I do like work outside my home dir 😬) have a devId of 64768 (nothing wrong with that…), but that that ID is given twice (!) in the list coming from procfs!

64768 ext4 / / ['rw', 'relatime'] /dev/mapper/nvme0n1p6_crypt ['rw', 'errors=remount-ro']
...(other entries)
64768 ext4 /usr/share/hunspell /var/snap/firefox/common/host-hunspell ['ro', 'noexec', 'noatime'] /dev/mapper/nvme0n1p6_crypt ['rw', 'errors=remount-ro']
...(other entries)

The first one looks sane (my “root mount“) the second doesn't. Reboot didn't help by the way.

I did two fixes (each one having effect in my case) • first one wins (won't get „wiped“), so far last one won. – of course it's a gamble, if the more correct mount is truly listed earlier • filter out 'snaps' (and while we're at it several others, like /proc, /proc/, /proc/something… but not /procedures (perhaps that's a valid mount, eh?)

The result looks good on my machine (essentially like df, not missing anything. (nb: I do have LUKS encryption, distinct boot partition and a Samba-share, all good, all there)

sindresorhus commented 1 year ago

Make sure to run npm test locally before committing.

nocke commented 1 year ago

Hi.

• rolled back version • fixed linting

sindresorhus commented 1 year ago

Thanks :)