Re: Reliable/safe way of removing empty maildirs?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday, December 6 at 09:15 PM, quoth A Darren Dunham:
> Perhaps I've misunderstood the reason for doing this, but I would
> just ask find to do a rmdir, and let it fail if the directory isn't
> empty.
>
> find dir -depth -type d -exec rmdir {} \;
>
> If 'dir' is still around when that finishes, it's probably because
> there's a file in there now. In the meantime, it's removed all empty
> subtrees.
That would work flawlessly on MH directories, but Maildir's are
slightly more complicated---they consist of several directories. Your
find command will indeed not erase mail that was delivered right when
you wanted it to be, however it will corrupt the Maildir.
For example, if I think I have an empty Maildir named "dir", then
on-disk it should look like this:
dir/
+- cur/
+- new/
`- tmp/
If, without my knowledge, email was delivered to it, it will look like
this:
dir/
+- cur/
+- new/
| `- a_message_file
`- tmp/
If I then run your find command, it will delete the two empty
components (tmp and cur) and will leave me with an unreadable
corrupted Maildir that looks like this:
dir
`- new
`- a_message_file
I would have to realize what has happened and then re-create the
missing directories in order to make things behave properly.
So, you're right that your command doesn't irrecoverably destroy
email... but it's still not very convenient.
~Kyle
- --
We are all worms, but I do believe I am a glow worm.
-- Winston Churchill
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFHWG6GBkIOoMqOI14RAgA0AJ95IP1zV0NNy0LZGvn6QOHOweS3GgCgoPrw
8qI9KmQwaWDPT804NGTI5Wk=
=BUoH
-----END PGP SIGNATURE-----