Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add updated-files threshold limit for sync #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ It supports Windows, Linux and macOS and requires at least python3.7.
`py -3 snapraid-runner.py` on Windows.

## Features
* Runs `diff` before `sync` to see how many files were deleted and aborts if
that number exceeds a set threshold.
* Runs `diff` before `sync` to see how many files were deleted or updated and aborts if
those numbers exceed set thresholds.
* Can create a size-limited rotated logfile.
* Can send notification emails after each run or only for failures.
* Can run `scrub` after `sync`
Expand Down
2 changes: 2 additions & 0 deletions snapraid-runner.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ executable = snapraid
config = snapraid.conf
; abort operation if there are more deletes than this, set to -1 to disable
deletethreshold = 40
; abort operation if there are more updates than this, set to -1 to disable
updatethreshold = 100
; if you want touch to be ran each time
touch = false

Expand Down
9 changes: 8 additions & 1 deletion snapraid-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def load_config(args):
config[section][k] = v.strip()

int_options = [
("snapraid", "deletethreshold"), ("logging", "maxsize"),
("snapraid", "deletethreshold"), ("snapraid", "updatethreshold"), ("logging", "maxsize"),
("scrub", "percentage"), ("scrub", "older-than"), ("email", "maxsize"),
]
for section, option in int_options:
Expand Down Expand Up @@ -273,6 +273,13 @@ def run():
config["snapraid"]["deletethreshold"]))
finish(False)

if (config["snapraid"]["updatethreshold"] >= 0 and
diff_results["update"] > config["snapraid"]["updatethreshold"]):
logging.error(
"Updated files exceed update threshold of {}, aborting".format(
config["snapraid"]["updatethreshold"]))
finish(False)

if (diff_results["remove"] + diff_results["add"] + diff_results["move"] +
diff_results["update"] == 0):
logging.info("No changes detected, no sync required")
Expand Down