Release URBM 2026.06.15.r008

This commit is contained in:
Mikei386
2026-06-15 07:17:37 +02:00
parent b0fa11a40a
commit 5e68a50373
13 changed files with 143 additions and 14 deletions
+22
View File
@@ -91,6 +91,12 @@ type Progress struct {
type ProgressCallback func(Progress)
type Stats struct {
TotalSize int64 `json:"total_size"`
TotalFileCount int64 `json:"total_file_count"`
TotalBlobCount int64 `json:"total_blob_count"`
}
func (r *Runner) Init(ctx context.Context, repo model.Repository) error {
return r.run(ctx, repo, []string{"init"}, nil, nil)
}
@@ -191,6 +197,22 @@ func (r *Runner) Snapshots(ctx context.Context, repo model.Repository) ([]model.
return snapshots, nil
}
func (r *Runner) Stats(ctx context.Context, repo model.Repository, mode string) (Stats, error) {
args := []string{"stats", "--json"}
if mode != "" {
args = append(args, "--mode", mode)
}
var output []byte
if err := r.run(ctx, repo, args, nil, &output); err != nil {
return Stats{}, err
}
var stats Stats
if err := json.Unmarshal(output, &stats); err != nil {
return Stats{}, fmt.Errorf("decode repository stats: %w", err)
}
return stats, nil
}
func (r *Runner) List(ctx context.Context, repo model.Repository, snapshot, path string) ([]map[string]any, error) {
args := []string{"ls", snapshot, "--json"}
if path != "" {
+25
View File
@@ -82,6 +82,31 @@ func TestBackupImageStreamsRawDeviceWithStableFilename(t *testing.T) {
}
}
func TestStatsUsesRequestedRepositoryCountingMode(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' '{\"total_size\":4096,\"total_file_count\":12,\"total_blob_count\":8}'\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"}
stats, err := runner.Stats(context.Background(), repo, "raw-data")
if err != nil {
t.Fatal(err)
}
if stats.TotalSize != 4096 || stats.TotalFileCount != 12 || stats.TotalBlobCount != 8 {
t.Fatalf("unexpected stats: %+v", stats)
}
args, _ := os.ReadFile(argsPath)
for _, expected := range []string{"stats", "--json", "--mode", "raw-data"} {
if !strings.Contains(string(args), expected) {
t.Fatalf("arguments missing %q: %s", expected, args)
}
}
}
func TestForgetUsesAgeAndCalendarRetention(t *testing.T) {
dir := t.TempDir()
argsPath := filepath.Join(dir, "args")