even if someone asked to keep the temporary data, they don't want
to see 5000 empty directries. Non-empty directories will remain.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
if not opts.preserve_tempdir:
logger.info("Removing temporary directory")
shutil.rmtree(tempdir)
-
+ else:
+ # delete the empty directories anyway. There are thousands of
+ # them and they're EMPTY.
+ for d in os.listdir(tempdir):
+ if d.startswith('conversation-'):
+ path = os.path.join(tempdir, d)
+ try:
+ os.rmdir(path)
+ except OSError as e:
+ logger.info("not removing %s (%s)" % (path, e))
main()