Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows installation for restic 0.17.1 #474

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/env/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ConfigFilePath() string {
if val := os.Getenv(EnvVarConfigPath); val != "" {
return val
}
return path.Join(getConfigDir(), "backrest/config.json")
return filepath.Join(getConfigDir(), "backrest", "config.json")
}

// DataDir
Expand All @@ -50,7 +50,7 @@ func DataDir() string {
}

if runtime.GOOS == "windows" {
return path.Join(getConfigDir(), "backrest/data")
return filepath.Join(getConfigDir(), "backrest", "data")
}
return path.Join(getHomeDir(), ".local/share/backrest")
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func getConfigDir() string {
if val := os.Getenv("XDG_CONFIG_HOME"); val != "" {
return val
}
return path.Join(getHomeDir(), ".config")
return filepath.Join(getHomeDir(), ".config")
}

func formatBindAddress(addr string) string {
Expand Down
5 changes: 3 additions & 2 deletions internal/resticinstaller/resticinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
Expand Down Expand Up @@ -245,8 +246,8 @@ func FindOrInstallResticBinary() (string, error) {
// Check for restic installation in data directory.
resticInstallPath := path.Join(env.DataDir(), resticBinName)
if runtime.GOOS == "windows" {
programFiles := os.Getenv("programfiles")
resticInstallPath = path.Join(programFiles, "backrest", resticBinName)
// on windows use a path relative to the executable.
resticInstallPath, _ = filepath.Abs(path.Join(path.Dir(os.Args[0]), resticBinName))
}

// Install restic if not found.
Expand Down
6 changes: 1 addition & 5 deletions pkg/restic/restic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,8 @@ func TestResticPartialBackup(t *testing.T) {
t.Fatalf("wanted summary, got: nil")
}

if summary.TotalFilesProcessed != 0 {
t.Errorf("wanted 0 files, got: %d", summary.TotalFilesProcessed)
}

if !slices.ContainsFunc(entries, func(e BackupProgressEntry) bool {
return e.MessageType == "error" && e.Item == unreadablePath
return e.MessageType == "error" && strings.Contains(e.Item, unreadablePath)
}) {
t.Errorf("wanted entries to contain an error event for the unreadable file (%s), but did not find it", unreadablePath)
t.Logf("entries:\n")
Expand Down
Loading