Fixed code that used the wrong path manipulation module
This commit is contained in:
parent
88757ef736
commit
211adff0b0
4 changed files with 10 additions and 10 deletions
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -15,17 +15,17 @@ const (
|
||||||
func (c *Config) checkStateFile() {
|
func (c *Config) checkStateFile() {
|
||||||
// Finds the state file to parse
|
// Finds the state file to parse
|
||||||
if c.stateFile != "" {
|
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)
|
info, err := os.Stat(c.stateFile)
|
||||||
if os.IsNotExist(err) || info.IsDir() {
|
if os.IsNotExist(err) || info.IsDir() {
|
||||||
fmt.Printf("INFO The state file %s does not exist.\n", c.stateFile)
|
fmt.Printf("INFO The state file %s does not exist.\n", c.stateFile)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.stateFile = path.Join(c.workDir, bareosStateFile)
|
c.stateFile = filepath.Join(c.workDir, bareosStateFile)
|
||||||
info, err := os.Stat(c.stateFile)
|
info, err := os.Stat(c.stateFile)
|
||||||
if os.IsNotExist(err) || info.IsDir() {
|
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)
|
info, err = os.Stat(c.stateFile)
|
||||||
if os.IsNotExist(err) || info.IsDir() {
|
if os.IsNotExist(err) || info.IsDir() {
|
||||||
fmt.Println("INFO Could not find a suitable state file. Has a job ever run?")
|
fmt.Println("INFO Could not find a suitable state file. Has a job ever run?")
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -33,7 +33,7 @@ func (c *Config) checkWorkDir() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.workDir = path.Clean(c.workDir)
|
c.workDir = filepath.Clean(c.workDir)
|
||||||
if c.verbose {
|
if c.verbose {
|
||||||
log.Println("Setting work directory to ", c.workDir)
|
log.Println("Setting work directory to ", c.workDir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import (
|
||||||
func (s *Spool) Load(c *config.Config) (err error) {
|
func (s *Spool) Load(c *config.Config) (err error) {
|
||||||
s.config = c
|
s.config = c
|
||||||
// We read the spool
|
// We read the spool
|
||||||
file, err := os.Open(path.Join(c.WorkDir(), spoolFile))
|
file, err := os.Open(filepath.Join(c.WorkDir(), spoolFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Couldn't open spool file, starting from scratch: %s", err)
|
return fmt.Errorf("Couldn't open spool file, starting from scratch: %s", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ import (
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Save writes a spool on the disk
|
// Save writes a spool on the disk
|
||||||
func (s *Spool) Save() (err error) {
|
func (s *Spool) Save() (err error) {
|
||||||
file, err := os.Create(path.Join(s.config.WorkDir(), spoolFile))
|
file, err := os.Create(filepath.Join(s.config.WorkDir(), spoolFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue