Skip to content
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: 4 additions & 0 deletions snapraid-runner.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ enabled = false
plan = 12
; minimum block age (in days) for scrubbing. Only used with percentage plans
older-than = 10

[sync]
; set to true to force sync files with zero size
force-zero = false
12 changes: 9 additions & 3 deletions snapraid-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def snapraid_command(command, args={}, *, allow_statuscodes=[]):
arguments = ["--conf", config["snapraid"]["config"],
"--quiet"]
for (k, v) in args.items():
arguments.extend(["--" + k, str(v)])
arguments.append("--" + k)
if v != '':
arguments.append(str(v))
p = subprocess.Popen(
[config["snapraid"]["executable"], command] + arguments,
stdout=subprocess.PIPE,
Expand Down Expand Up @@ -133,7 +135,7 @@ def load_config(args):
global config
parser = configparser.RawConfigParser()
parser.read(args.conf)
sections = ["snapraid", "logging", "email", "smtp", "scrub"]
sections = ["snapraid", "logging", "email", "smtp", "scrub", "sync"]
config = dict((x, defaultdict(lambda: "")) for x in sections)
for section in parser.sections():
for (k, v) in parser.items(section):
Expand All @@ -154,6 +156,7 @@ def load_config(args):
config["scrub"]["enabled"] = (config["scrub"]["enabled"].lower() == "true")
config["email"]["short"] = (config["email"]["short"].lower() == "true")
config["snapraid"]["touch"] = (config["snapraid"]["touch"].lower() == "true")
config["sync"]["force-zero"] = (config["sync"]["force-zero"].lower() == "true")

# Migration
if config["scrub"]["percentage"]:
Expand Down Expand Up @@ -281,8 +284,11 @@ def run():
logging.info("No changes detected, no sync required")
else:
logging.info("Running sync...")
sync_args: dict[str, str] = {}
if config["sync"]["force-zero"]:
sync_args["force-zero"] = ""
try:
snapraid_command("sync")
snapraid_command("sync", sync_args)
except subprocess.CalledProcessError as e:
logging.error(e)
finish(False)
Expand Down