|
|
@ -3,6 +3,7 @@ package internal
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/cupcakearmy/autorestic/internal/colors"
|
|
|
|
"github.com/cupcakearmy/autorestic/internal/colors"
|
|
|
@ -18,20 +19,33 @@ const (
|
|
|
|
RUNNING = "running"
|
|
|
|
RUNNING = "running"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// getLockfilePath returns the path to the lockfile. If flags.LOCKFILE_PATH is
|
|
|
|
// getLockfilePath returns the path to the lockfile. The path for the lockfile
|
|
|
|
// set, its value is used, otherwise the path is generated relative to the
|
|
|
|
// can be sources from multiple places If flags.LOCKFILE_PATH is set, its value
|
|
|
|
// config file.
|
|
|
|
// is used; if the config has the `lockfile` option set, its value is used;
|
|
|
|
|
|
|
|
// otherwise the path is generated relative to the config file.
|
|
|
|
func getLockfilePath() string {
|
|
|
|
func getLockfilePath() string {
|
|
|
|
if flags.LOCKFILE_PATH != "" {
|
|
|
|
if flags.LOCKFILE_PATH != "" {
|
|
|
|
return flags.LOCKFILE_PATH
|
|
|
|
abs, err := filepath.Abs(flags.LOCKFILE_PATH)
|
|
|
|
} else {
|
|
|
|
if err != nil {
|
|
|
|
p := viper.ConfigFileUsed()
|
|
|
|
return flags.LOCKFILE_PATH
|
|
|
|
if p == "" {
|
|
|
|
}
|
|
|
|
colors.Error.Println("cannot lock before reading config location")
|
|
|
|
return abs
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if lockfile := GetConfig().Lockfile; lockfile != "" {
|
|
|
|
|
|
|
|
abs, err := filepath.Abs(lockfile)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return lockfile
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return path.Join(path.Dir(p), ".autorestic.lock.yml")
|
|
|
|
return abs
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p := viper.ConfigFileUsed()
|
|
|
|
|
|
|
|
if p == "" {
|
|
|
|
|
|
|
|
colors.Error.Println("cannot lock before reading config location")
|
|
|
|
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.Join(path.Dir(p), ".autorestic.lock.yml")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func getLock() *viper.Viper {
|
|
|
|
func getLock() *viper.Viper {
|
|
|
|