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 8d99bc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/orchestrator/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"path"
"runtime"
"slices"
"sort"
"strings"
Expand Down Expand Up @@ -305,13 +306,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", snapshotPath))
} 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 8d99bc3

Please sign in to comment.