|
|
|
@ -6,6 +6,8 @@ import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/rs/zerolog/log"
|
|
|
|
|
"github.com/skratchdot/open-golang/open"
|
|
|
|
|
"os"
|
|
|
|
|
"os/exec"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"time"
|
|
|
|
@ -58,10 +60,9 @@ func (w *Wrapper) Cleanup() {
|
|
|
|
|
func resticCmdFn(args ...string) *exec.Cmd {
|
|
|
|
|
// Running from GoLand: could be /private/var/folders/5s/csgpcjlx1wg9659_485vqz880000gn/T/GoLand/restictray
|
|
|
|
|
// Installed: could be /Applications/restictray/restictray.app/Contents/MacOS/restictray
|
|
|
|
|
// This isn't ideal but I don't want to fiddle with build flags
|
|
|
|
|
resticExec := filepath.Join(filepath.Dir(executable), "restic")
|
|
|
|
|
if IsDev() {
|
|
|
|
|
resticExec = "restic" // dev: assume in $PATH
|
|
|
|
|
if _, err := os.Stat(resticExec); os.IsNotExist(err) {
|
|
|
|
|
resticExec = "restic" // can't find embedded exec, assume in $PATH
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmd := exec.Command(resticExec, args...)
|
|
|
|
@ -90,23 +91,18 @@ func (w *Wrapper) MountBackups(c *Config) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OpenConfigFile opens the restic config file using the NON-BLOCKING "open" command.
|
|
|
|
|
// OpenConfigFile opens the restic config file using the open command.
|
|
|
|
|
func OpenConfigFile() error {
|
|
|
|
|
return exec.Command("open", ConfigFile()).Run()
|
|
|
|
|
return open.Run(ConfigFile())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OpenLogs opens the restic logfile using the NON-BLOCKING "open" command.
|
|
|
|
|
// OpenLogs opens the restic logfile using the open command.
|
|
|
|
|
func OpenLogs() error {
|
|
|
|
|
return exec.Command("open", LogFile()).Run()
|
|
|
|
|
return open.Run(LogFile())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func openFolder(folder string) error {
|
|
|
|
|
cmd := exec.Command("open", folder)
|
|
|
|
|
out, err := cmd.CombinedOutput()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("open mount dir: %s: %w", string(out), err)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
return open.Run(folder)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateLatestSnapshots updates LatestSnapshots or returns an error. If timed out, returns an error as well.
|
|
|
|
|