diff --git a/README.md b/README.md index 1e48076..ca28549 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ feature you are missing, you can have a look ## Changelog ### Unreleased * Add --ignore-deletethreshold (by exterrestris, #25) -* Add support for scrub --plan, replacing --percentage +* Add support for scrub --plan, replacing --percentage (thanks to fmoledina) * Remove snapraid progress output. Was accidentially introduced with python3 support. ### v0.5 (26 Feb 2021) * Remove (broken) python2 support -* Fix snapraid output encoding handling (by hyyz17200, #31) +* Fix snapraid output encoding handling (by hyyz17200, #31) * Fix log rotation (by ptoulouse, #36) ### v0.4 (17 Aug 2019) diff --git a/snapraid-runner.conf.example b/snapraid-runner.conf.example index 14f2e20..bc8fca4 100644 --- a/snapraid-runner.conf.example +++ b/snapraid-runner.conf.example @@ -40,4 +40,5 @@ password = enabled = false ; scrub plan - either a percentage or one of [bad, new, full] plan = 12 +; minimum block age (in days) for scrubbing. Only used with percentage plans older-than = 10 diff --git a/snapraid-runner.py b/snapraid-runner.py index e45b2fa..56b8e9e 100644 --- a/snapraid-runner.py +++ b/snapraid-runner.py @@ -291,10 +291,17 @@ def run(): if config["scrub"]["enabled"]: logging.info("Running scrub...") try: - snapraid_command("scrub", { + # Check if a percentage plan was given + int(config["scrub"]["plan"]) + except ValueError: + scrub_args = {"plan": config["scrub"]["plan"]} + else: + scrub_args = { "plan": config["scrub"]["plan"], "older-than": config["scrub"]["older-than"], - }) + } + try: + snapraid_command("scrub", scrub_args) except subprocess.CalledProcessError as e: logging.error(e) finish(False)