aboutsummaryrefslogtreecommitdiff
path: root/spool/load.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-02-22 12:35:05 +0100
committerJulien Dessaux2020-02-22 12:56:29 +0100
commit2661ce9a2bda2b6c1efc0ba1fef873c9dc91bb7c (patch)
tree155f36ee7f62f972fc49e5df0440948a4ba0348c /spool/load.go
parentAdded tests to the state package, and reworked the code around that (diff)
downloadbareos-zabbix-check-2661ce9a2bda2b6c1efc0ba1fef873c9dc91bb7c.tar.gz
bareos-zabbix-check-2661ce9a2bda2b6c1efc0ba1fef873c9dc91bb7c.tar.bz2
bareos-zabbix-check-2661ce9a2bda2b6c1efc0ba1fef873c9dc91bb7c.zip
Added tests to the spool package, and reworked the code around that.
Diffstat (limited to '')
-rw-r--r--spool/load.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/spool/load.go b/spool/load.go
deleted file mode 100644
index 5b08bda..0000000
--- a/spool/load.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package spool
-
-import (
- "bareos-zabbix-check/config"
- "bareos-zabbix-check/job"
- "encoding/csv"
- "fmt"
- "log"
- "os"
- "path/filepath"
- "strconv"
-)
-
-// Load loads a spool file in path
-func (s *Spool) Load(c *config.Config) (err error) {
- s.config = c
- // We read the spool
- file, err := os.Open(filepath.Join(c.WorkDir(), spoolFile))
- if err != nil {
- return fmt.Errorf("Couldn't open spool file, starting from scratch: %s", err)
- }
- defer file.Close()
- lines, err := csv.NewReader(file).ReadAll()
- if err != nil {
- return fmt.Errorf("Corrupted spool file, starting from scratch : %s", err)
- }
- if c.Verbose() {
- log.Printf("Spool file content : %v\n", lines)
- }
-
- for _, line := range lines {
- var i int
- i, err = strconv.Atoi(line[1])
- if err != nil {
- return fmt.Errorf("Corrupted spool file : couldn't parse timestamp entry")
- }
- s.jobs = append(s.jobs, job.Job{Name: line[0], Timestamp: uint64(i), Success: true})
- }
- return
-}