Skip to content

Commit

Permalink
fix: test fixes for windows file restore
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed Aug 27, 2024
1 parent cc173aa commit 83db2a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/orchestrator/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,17 @@ func (r *RepoOrchestrator) Restore(ctx context.Context, snapshotId string, snaps
opts = append(opts, restic.WithFlags("--target", target))

if snapshotPath != "" {
dir := path.Dir(snapshotPath)
base := path.Base(snapshotPath)
if dir != "" {
snapshotId = snapshotId + ":" + dir
}
if base != "" {
opts = append(opts, restic.WithFlags("--include", base))
if runtime.GOOS == "windows" {
opts = append(opts, restic.WithFlags("--include", strings.ReplaceAll(snapshotPath))

Check failure on line 309 in internal/orchestrator/repo/repo.go

View workflow job for this annotation

GitHub Actions / test-nix

syntax error: unexpected newline in argument list; possibly missing comma or )

Check failure on line 309 in internal/orchestrator/repo/repo.go

View workflow job for this annotation

GitHub Actions / build

syntax error: unexpected newline in argument list; possibly missing comma or )

Check failure on line 309 in internal/orchestrator/repo/repo.go

View workflow job for this annotation

GitHub Actions / test-win

syntax error: unexpected newline in argument list; possibly missing comma or )
} else {
dir := path.Dir(snapshotPath)
base := path.Base(snapshotPath)
if dir != "" {
snapshotId = snapshotId + ":" + dir
}
if base != "" {
opts = append(opts, restic.WithFlags("--include", base))
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions internal/orchestrator/repo/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ func TestRestore(t *testing.T) {
t.Fatalf("expected 1 total file, got %d", restoreSummary.TotalFiles)
}

if runtime.GOOS == "windows" {
return
}

// Check the restored file
restoredFile := restoreDir + "/test.txt"
if _, err := os.Stat(restoredFile); err != nil {
Expand Down

0 comments on commit 83db2a0

Please sign in to comment.