Fix progress bar stuck: split on \r to get latest rsync progress
rsync --info=progress2 uses \r without \n, so the entire progress stream is one long line. Split on both \r and \n to parse each progress update independently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -131,23 +131,17 @@ class RunningTasksScreen(Screen):
|
|||||||
|
|
||||||
def _process_log_content(self, content: str, log_viewer: RichLog) -> None:
|
def _process_log_content(self, content: str, log_viewer: RichLog) -> None:
|
||||||
"""Process log content, extracting rsync progress and writing log lines."""
|
"""Process log content, extracting rsync progress and writing log lines."""
|
||||||
for line in content.split("\n"):
|
# Split on both \n and \r to handle rsync --info=progress2 output
|
||||||
if not line:
|
parts = re.split(r"[\r\n]+", content)
|
||||||
|
for part in parts:
|
||||||
|
part = part.strip()
|
||||||
|
if not part:
|
||||||
continue
|
continue
|
||||||
# rsync --info=progress2 uses \r to update in place
|
m = _PROGRESS_RE.search(part)
|
||||||
if "\r" in line:
|
if m and ("xfr#" in part or "to-chk=" in part or "MB/s" in part or "kB/s" in part or "GB/s" in part):
|
||||||
parts = line.split("\r")
|
self._update_progress(part)
|
||||||
# Extract progress from the last \r segment
|
|
||||||
last = parts[-1].strip()
|
|
||||||
if last:
|
|
||||||
self._update_progress(last)
|
|
||||||
# Write non-progress parts as log lines
|
|
||||||
for part in parts:
|
|
||||||
part = part.strip()
|
|
||||||
if part and not _PROGRESS_RE.search(part):
|
|
||||||
log_viewer.write(part)
|
|
||||||
else:
|
else:
|
||||||
log_viewer.write(line)
|
log_viewer.write(part)
|
||||||
|
|
||||||
def _update_progress(self, text: str) -> None:
|
def _update_progress(self, text: str) -> None:
|
||||||
"""Parse rsync progress2 line and update progress bar."""
|
"""Parse rsync progress2 line and update progress bar."""
|
||||||
|
|||||||
Reference in New Issue
Block a user