1
0
Fork 0

Fixed code that used the wrong path manipulation module

This commit is contained in:
Julien Dessaux 2020-02-12 21:04:55 +01:00
parent 88757ef736
commit 211adff0b0
4 changed files with 10 additions and 10 deletions

View file

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
)
const (
@ -15,17 +15,17 @@ const (
func (c *Config) checkStateFile() {
// Finds the state file to parse
if c.stateFile != "" {
c.stateFile = path.Join(c.workDir, c.stateFile)
c.stateFile = filepath.Join(c.workDir, c.stateFile)
info, err := os.Stat(c.stateFile)
if os.IsNotExist(err) || info.IsDir() {
fmt.Printf("INFO The state file %s does not exist.\n", c.stateFile)
os.Exit(0)
}
} else {
c.stateFile = path.Join(c.workDir, bareosStateFile)
c.stateFile = filepath.Join(c.workDir, bareosStateFile)
info, err := os.Stat(c.stateFile)
if os.IsNotExist(err) || info.IsDir() {
c.stateFile = path.Join(c.workDir, baculaStateFile)
c.stateFile = filepath.Join(c.workDir, baculaStateFile)
info, err = os.Stat(c.stateFile)
if os.IsNotExist(err) || info.IsDir() {
fmt.Println("INFO Could not find a suitable state file. Has a job ever run?")

View file

@ -4,7 +4,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
)
const (
@ -33,7 +33,7 @@ func (c *Config) checkWorkDir() {
}
}
}
c.workDir = path.Clean(c.workDir)
c.workDir = filepath.Clean(c.workDir)
if c.verbose {
log.Println("Setting work directory to ", c.workDir)
}