Add Restic read concurrency setting

This commit is contained in:
Mikei386
2026-06-15 20:49:51 +02:00
parent bb6b3211e9
commit 84df215ad0
12 changed files with 79 additions and 28 deletions
+3
View File
@@ -121,6 +121,9 @@ func (r *Runner) TestPassword(ctx context.Context, repo model.Repository, passwo
func (r *Runner) Backup(ctx context.Context, repo model.Repository, job model.Job, sources []string, progress ProgressCallback) (Summary, error) {
args := []string{"backup", "--json", "--compression", job.Compression}
if job.ReadConcurrency > 0 {
args = append(args, "--read-concurrency", fmt.Sprint(job.ReadConcurrency))
}
for _, tag := range append([]string{"urbm", "job:" + job.ID}, job.Tags...) {
args = append(args, "--tag", tag)
}
+23
View File
@@ -110,6 +110,29 @@ func TestBackupLimitsCPUForThisJob(t *testing.T) {
}
}
func TestBackupSetsReadConcurrencyForThisJob(t *testing.T) {
dir := t.TempDir()
argsPath := filepath.Join(dir, "args")
script := filepath.Join(dir, "restic")
body := fmt.Sprintf("#!/bin/sh\nprintf '%%s\\n' \"$@\" > '%s'\nprintf '%%s\\n' '{\"message_type\":\"summary\",\"snapshot_id\":\"read123\"}'\n", argsPath)
if err := os.WriteFile(script, []byte(body), 0700); err != nil {
t.Fatal(err)
}
runner := &Runner{Binary: script, RuntimeDir: dir, Secrets: fakeSecrets{"password": "secret"}}
repo := model.Repository{Type: model.RepositoryLocal, Location: "/repo", PasswordRef: "password"}
job := model.Job{ID: "job", Compression: "auto", ReadConcurrency: 8}
if _, err := runner.Backup(context.Background(), repo, job, []string{"/source"}, nil); err != nil {
t.Fatal(err)
}
args, err := os.ReadFile(argsPath)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(string(args), "--read-concurrency\n8\n") {
t.Fatalf("read concurrency missing from arguments: %s", args)
}
}
func TestBackupImageStreamsRawDeviceWithStableFilename(t *testing.T) {
dir := t.TempDir()
argsPath := filepath.Join(dir, "args")