[tor-commits] [sbws/master] Clean files depending on args
pastly at torproject.org
pastly at torproject.org
Thu Aug 9 14:21:19 UTC 2018
commit 8926c2b945080dc930e8db039279b6c6aff78ee8
Author: juga0 <juga at riseup.net>
Date: Tue Jul 17 17:15:58 2018 +0000
Clean files depending on args
---
sbws/core/cleanup.py | 55 +++++++++++++++++++++++++++++-----------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/sbws/core/cleanup.py b/sbws/core/cleanup.py
index 04823b1..852b8e6 100644
--- a/sbws/core/cleanup.py
+++ b/sbws/core/cleanup.py
@@ -194,27 +194,34 @@ def main(args, conf):
if not is_initted(args.directory):
fail_hard('Sbws isn\'t initialized. Try sbws init')
- datadir = conf['paths']['datadir']
- if not os.path.isdir(datadir):
- fail_hard('%s does not exist', datadir)
-
- fresh_days = conf.getint('general', 'data_period')
- stale_days = conf.getint('cleanup', 'stale_days')
- rotten_days = conf.getint('cleanup', 'rotten_days')
- if stale_days - 2 < fresh_days:
- fail_hard('For safetly, cleanup/stale_days (%d) must be at least 2 '
- 'days larger than general/data_period (%d)', stale_days,
- fresh_days)
- if rotten_days < stale_days:
- fail_hard('cleanup/rotten_days (%d) must be the same or larger than '
- 'cleanup/stale_days (%d)', rotten_days, stale_days)
-
- if stale_days / 2 < fresh_days:
- log.warning(
- 'cleanup/stale_days (%d) is less than twice '
- 'general/data_period (%d). For ease of parsing older results '
- 'if necessary, it is recommended to make stale_days at least '
- 'twice the data_period.', stale_days, fresh_days)
-
- _remove_rotten_files(datadir, rotten_days, dry_run=args.dry_run)
- _compress_stale_files(datadir, stale_days, dry_run=args.dry_run)
+ if args.no_results and args.no_v3bw:
+ fail_hard('Nothing to clean.')
+
+ if not args.no_results:
+ datadir = conf['paths']['datadir']
+ if not os.path.isdir(datadir):
+ fail_hard('%s does not exist', datadir)
+
+ fresh_days = conf.getint('general', 'data_period')
+ stale_days = conf.getint('cleanup', 'stale_days')
+ rotten_days = conf.getint('cleanup', 'rotten_days')
+ if stale_days - 2 < fresh_days:
+ fail_hard('For safetly, cleanup/stale_days (%d) must be at least '
+ '2 days larger than general/data_period (%d)',
+ stale_days, fresh_days)
+ if rotten_days < stale_days:
+ fail_hard('cleanup/rotten_days (%d) must be the same or larger '
+ 'than cleanup/stale_days (%d)', rotten_days, stale_days)
+
+ if stale_days / 2 < fresh_days:
+ log.warning(
+ 'cleanup/stale_days (%d) is less than twice '
+ 'general/data_period (%d). For ease of parsing older results '
+ 'if necessary, it is recommended to make stale_days at least '
+ 'twice the data_period.', stale_days, fresh_days)
+
+ _remove_rotten_files(datadir, rotten_days, dry_run=args.dry_run)
+ _compress_stale_files(datadir, stale_days, dry_run=args.dry_run)
+
+ if not args.no_v3bw:
+ _clean_v3bw_files(args, conf)
More information about the tor-commits
mailing list