<<< Date Index >>>     <<< Thread Index >>>

Re: Reliable/safe way of removing empty maildirs?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday, December  6 at 04:46 PM, quoth Rado S:
>=- Chris G wrote on Thu  6.Dec'07 at 13:03:13 +0000 -=
>
>> What's a reliable way of removing empty maildirs?
>> Presumably it's possible but you'd have to follow some protocol that
>> wouldn't interfere with the proper writing of messages to the maildir.
>
>chmod a-w dir/new
>rm -rf dir

Well, that's not *quite* safe, now is it? There's a race condition 
between deciding that a maildir is empty and then changing the 
permissions such that no one can deliver mail to it. It would have to 
be more like this:

chmod a-w dir/new
if [ `find dir -type f` ] ; then
     echo "Not empty!"
     chmod a+w dir/new
else
     rm -rf dir
fi

~Kyle
- -- 
I think we ought always to entertain our opinions with some measure of 
doubt. I shouldn't wish people dogmatically to believe any philosophy, 
not even mine.
                                                    -- Bertrand Russell
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iD8DBQFHWB1IBkIOoMqOI14RAp8LAJ0YXKrpUr9TCwaswVpky/MF8UH6rACgiECX
1CKaU1As7wX9YrRyQPy50Cw=
=ibUG
-----END PGP SIGNATURE-----