Fix rsync space estimation with carriage-return progress; release 2026.10.15.r001
This commit is contained in:
1 parent
62d765d629
commit
a7dbd77492
8 files changed
+99
-13
No files matched your search
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
||||
e4a9906820384c0bff708c02d81a8915b7d5e034984052e42bf7c09761a47a31 urbm-2026.10.15.r001-x86_64-1.txz
|
||||
Vendored
+7
-2
@@ -2,13 +2,18 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "urbm">
|
||||
<!ENTITY author "Michael Roll">
|
||||
<!ENTITY version "2026.10.09.r001">
|
||||
<!ENTITY version "2026.10.15.r001">
|
||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm.plg">
|
||||
<!ENTITY packageURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm-&version;-x86_64-1.txz">
|
||||
<!ENTITY packageSHA256 "b9cde8f34560cc4a5a5699f9f2ed2e0b8fe72d625dcb63c65ea1240aeeaf44de">
|
||||
<!ENTITY packageSHA256 "e4a9906820384c0bff708c02d81a8915b7d5e034984052e42bf7c09761a47a31">
|
||||
]>
|
||||
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="7.0.0" support="https://git.casaderoll.de/michael/URBM/issues" icon="urbm.png">
|
||||
<CHANGES>
|
||||
### 2026.10.15.r001
|
||||
- Parse carriage-return progress updates during Rsync space estimation instead of accumulating oversized lines.
|
||||
- Share the streaming parser with the copy runner and report output-read failures without blocking the child process.
|
||||
- Cover multi-megabyte progress output, mixed line endings and oversized-token draining with synthetic regression tests.
|
||||
|
||||
### 2026.10.09.r001
|
||||
- Estimate additional Rsync destination space separately from transfer volume.
|
||||
- Account for replacement files, sparse allocation, temporary copies and a safety reserve; never credit delayed deletions early.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# Rsync preflight Scanner failure
|
||||
|
||||
Rsync `--info=progress2` updates can be separated by carriage returns rather than
|
||||
newlines. Estimate previously used Scanner's default ScanLines, so enough
|
||||
updates formed a token larger than its configured 2 MiB maximum. The preflight
|
||||
then correctly refused to proceed with an unknown estimate, but users could
|
||||
mistake the error for insufficient destination capacity.
|
||||
|
||||
Estimate now shares the copy runner's CR/LF-aware streaming parser. The common
|
||||
parser returns read errors and drains the remaining pipe after a parse failure,
|
||||
preventing a blocked producer. Run now propagates these errors instead of
|
||||
silently returning a potentially incomplete summary. The token bound remains
|
||||
2 MiB; free-space checks and deletion/overwrite settings are unchanged.
|
||||
|
||||
Synthetic regression: 100,000 CR-delimited progress updates followed by zero-file
|
||||
summary statistics. The previous source fails with `SpaceUnknown: bufio.Scanner:
|
||||
token too long`; the fixed source returns a known zero-byte estimate. Additional
|
||||
tests cover mixed CR/LF with an unterminated final line and oversized-token error
|
||||
reporting/draining. Existing real-rsync tests use temporary synthetic files only.
|
||||
No production backup data, configuration or logs were inspected or replayed.
|
||||
|
||||
Validation: all Go packages passed on Linux with Go 1.27.2 and system rsync;
|
||||
`go vet ./...`, shell syntax, migration fixture and JavaScript syntax passed.
|
||||
An initial full run exposed an unrelated intermittent Restic BackupImage summary
|
||||
test failure; that test passed three immediate repeats and the full rerun.
|
||||
This change does not fix or claim to resolve that separate Restic behavior.
|
||||
|
||||
Release 2026.10.15.r001 contains the fix. Publishing an update does not validate
|
||||
available capacity for a real job; the next real preflight still must succeed.
|
||||
+14
-9
@@ -91,9 +91,10 @@ func (r *Runner) Run(ctx context.Context, runID string, job model.Job, callback
|
||||
defer unregister()
|
||||
|
||||
var summary Summary
|
||||
var scanErr error
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
scanOutput(stdout, func(line string) {
|
||||
scanErr = scanOutput(stdout, func(line string) {
|
||||
summary.parseLine(line)
|
||||
if callback != nil {
|
||||
if progress, ok := parseProgress(line); ok {
|
||||
@@ -121,6 +122,9 @@ func (r *Runner) Run(ctx context.Context, runID string, job model.Job, callback
|
||||
}
|
||||
return Summary{}, fmt.Errorf("rsync: %s", message)
|
||||
}
|
||||
if scanErr != nil {
|
||||
return summary, fmt.Errorf("rsync output: %w", scanErr)
|
||||
}
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
@@ -176,16 +180,11 @@ func (r *Runner) Estimate(ctx context.Context, runID string, job model.Job) (Sum
|
||||
space := newSpaceEstimate(job.Rsync.Target)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
scanner.Buffer(make([]byte, 64*1024), 2*1024*1024)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if err := scanOutput(stdout, func(line string) {
|
||||
summary.parseLine(line)
|
||||
space.consume(line)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
}); err != nil {
|
||||
space.problem = err.Error()
|
||||
_, _ = io.Copy(io.Discard, stdout)
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
@@ -282,7 +281,7 @@ func (r *Runner) register(runID string, process *os.Process) func() {
|
||||
}
|
||||
}
|
||||
|
||||
func scanOutput(reader io.Reader, callback func(string)) {
|
||||
func scanOutput(reader io.Reader, callback func(string)) error {
|
||||
scanner := bufio.NewScanner(reader)
|
||||
scanner.Split(splitLinesAndCarriageReturns)
|
||||
scanner.Buffer(make([]byte, 64*1024), 2*1024*1024)
|
||||
@@ -291,6 +290,12 @@ func scanOutput(reader io.Reader, callback func(string)) {
|
||||
callback(line)
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
// Keep draining so rsync cannot block on a full stdout pipe before Wait.
|
||||
_, _ = io.Copy(io.Discard, reader)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func drainLimited(reader io.Reader, limit int) []byte {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.casaderoll.de/michael/urbm/internal/model"
|
||||
)
|
||||
@@ -170,3 +171,43 @@ func TestRealRsyncDryRunAndCopy(t *testing.T) {
|
||||
t.Fatalf("identical: %+v %v", identical, err)
|
||||
}
|
||||
}
|
||||
|
||||
// progress2 updates use CR without LF; a long comparison must not accumulate
|
||||
// them into one multi-megabyte Scanner token or hide its final statistics.
|
||||
func TestEstimateHandlesLongCarriageReturnProgress(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
output := filepath.Join(dir, "output")
|
||||
progress := strings.Repeat(" 1,234,567 42% 12.34MB/s 0:00:05\r", 100000)
|
||||
if err := os.WriteFile(output, []byte(progress+"\nNumber of regular files transferred: 0\nTotal transferred file size: 0 bytes\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
binary := filepath.Join(dir, "rsync")
|
||||
if err := os.WriteFile(binary, []byte("#!/bin/sh\ncat '"+output+"'\n"), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runner := Runner{Binary: binary}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
got, err := runner.Estimate(ctx, "cr-progress", model.Job{Rsync: model.RsyncOptions{Target: dir}})
|
||||
if err != nil || got.SpaceUnknown != "" || got.Files != 0 || got.Bytes != 0 || got.RequiredBytes != 0 {
|
||||
t.Fatalf("summary=%+v err=%v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanOutputMixedDelimitersAndFinalLine(t *testing.T) {
|
||||
var got []string
|
||||
err := scanOutput(strings.NewReader("one\rtwo\r\nthree\nfour"), func(s string) { got = append(got, s) })
|
||||
if err != nil || !slices.Equal(got, []string{"one", "two", "three", "four"}) {
|
||||
t.Fatalf("lines=%v err=%v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScanOutputReportsOversizedTokenAndDrains(t *testing.T) {
|
||||
input := strings.NewReader(strings.Repeat("x", 3*1024*1024) + "\nremaining\n")
|
||||
if err := scanOutput(input, func(string) {}); err == nil {
|
||||
t.Fatal("oversized output silently accepted")
|
||||
}
|
||||
if input.Len() != 0 {
|
||||
t.Fatalf("stdout not drained: %d bytes", input.Len())
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -2,13 +2,18 @@
|
||||
<!DOCTYPE PLUGIN [
|
||||
<!ENTITY name "urbm">
|
||||
<!ENTITY author "Michael Roll">
|
||||
<!ENTITY version "2026.10.09.r001">
|
||||
<!ENTITY version "2026.10.15.r001">
|
||||
<!ENTITY pluginURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm.plg">
|
||||
<!ENTITY packageURL "https://git.casaderoll.de/michael/URBM/raw/branch/main/dist/urbm-&version;-x86_64-1.txz">
|
||||
<!ENTITY packageSHA256 "REPLACE_DURING_RELEASE">
|
||||
]>
|
||||
<PLUGIN name="&name;" author="&author;" version="&version;" pluginURL="&pluginURL;" min="7.0.0" support="https://git.casaderoll.de/michael/URBM/issues" icon="urbm.png">
|
||||
<CHANGES>
|
||||
### 2026.10.15.r001
|
||||
- Parse carriage-return progress updates during Rsync space estimation instead of accumulating oversized lines.
|
||||
- Share the streaming parser with the copy runner and report output-read failures without blocking the child process.
|
||||
- Cover multi-megabyte progress output, mixed line endings and oversized-token draining with synthetic regression tests.
|
||||
|
||||
### 2026.10.09.r001
|
||||
- Estimate additional Rsync destination space separately from transfer volume.
|
||||
- Account for replacement files, sparse allocation, temporary copies and a safety reserve; never credit delayed deletions early.
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ Tag="URBM Unraid Restic Backup Manager backup snapshots restore"
|
||||
---
|
||||
<?php
|
||||
$pluginRoot = '/plugins/urbm';
|
||||
$urbmVersion = '2026.10.09.r001';
|
||||
$urbmVersion = '2026.10.15.r001';
|
||||
$urbmAssetVersion = preg_replace('/[^A-Za-z0-9]/', '', $urbmVersion);
|
||||
?>
|
||||
<link rel="stylesheet" href="<?= $pluginRoot ?>/assets/urbm.css?v=<?= $urbmAssetVersion ?>">
|
||||
|
||||
Reference in new issue
Block a user