Skip to content

Commit

Permalink
Merge branch 'release/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandaoc-io committed Jun 24, 2020
2 parents 2ef8dc6 + 6359fb5 commit 4165453
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/netintcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func networkInterfaceCheck(snmpVersion string, cmd *cobra.Command, args []string
asExp := false
err = file.CheckFileExist(file.DevicePath, "index.json")
if err == nil {
asExp = file.AsExp(file.DevicePath, "index.json", time.Duration(indexFileExp)*time.Minute)
asExp, err = file.AsExp(file.DevicePath, "index.json", time.Duration(indexFileExp)*time.Minute)
if err != nil {
sknchk.Unknown(fmt.Sprintf("Error while accessing Index file : %v", err), "")
}
if asExp {
log.Debugln("Regeneration of the file...")
}
Expand Down
8 changes: 4 additions & 4 deletions file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ func CreatePath(fPath string) error {
}

//AsExp check if the file is older than the given expiration duration
func AsExp(devicePath string, filename string, exptime time.Duration) bool {
func AsExp(devicePath string, filename string, exptime time.Duration) (bool, error) {
log.Debugln("===== File expiration check =====")
file, err := os.Stat(path.Join(devicePath, filename))
log.Debugf("Tested file : %v", path.Join(devicePath, filename))
if err != nil {
return false
return false, err
}
log.Debugf("Expiration delay : %v", exptime)
modifiedtime := file.ModTime()
Expand All @@ -71,10 +71,10 @@ func AsExp(devicePath string, filename string, exptime time.Duration) bool {
log.Debugf("Last modification time : %s ago", elapsed)
if elapsed > exptime {
log.Debugln("The file have expired")
return true
return true, nil
}
log.Debugln("The file haven't expired")
return false
return false, nil
}

//CreateJSONFile will create a json file bases on the interface{} datas.
Expand Down

0 comments on commit 4165453

Please sign in to comment.