fix: line-buffer sync output so a redirected log shows progress live

A sync runs for hours and is normally watched through a redirected log,
where Python's block buffering withheld the per-source progress lines
until they happened to flush. The gallery-dl subprocesses write to the
same descriptor unbuffered, so the log also interleaved out of order.

Reconfiguring the streams in-process rather than relying on `python3 -u`
means it holds however the script is invoked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-16 22:48:40 -04:00
co-authored by Claude Opus 5
parent 0ac1ef951f
commit 3e29976866
+7
View File
@@ -484,6 +484,13 @@ def publish(staging: Path, dest: str, dry_run: bool) -> int:
def main() -> int: def main() -> int:
# A sync runs for hours and is normally watched through a redirected log,
# where Python's block buffering would withhold progress until it happened
# to flush -- and the gallery-dl subprocesses write to the same descriptor
# unbuffered, so the log would also interleave out of order.
sys.stdout.reconfigure(line_buffering=True)
sys.stderr.reconfigure(line_buffering=True)
ap = argparse.ArgumentParser(description=__doc__, ap = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter) formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--index", required=True, ap.add_argument("--index", required=True,