From: Douglas Bagnall Date: Fri, 19 Oct 2018 03:25:06 +0000 (+1300) Subject: traffic: delete empty temp directories X-Git-Tag: tdb-1.3.17~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b77ee628cc893bea64f72e7035d21904909e8cc1;p=thirdparty%2Fsamba.git traffic: delete empty temp directories 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 Reviewed-by: Andrew Bartlett --- diff --git a/script/traffic_replay b/script/traffic_replay index e267935b9dd..dd6e9037ce5 100755 --- a/script/traffic_replay +++ b/script/traffic_replay @@ -387,6 +387,15 @@ def main(): 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()