Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Added checking if provided temp_dir_path exists
Browse files Browse the repository at this point in the history
  • Loading branch information
IzabellaRaulin committed Mar 22, 2017
1 parent cc39d1a commit c535438
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 2 additions & 6 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,7 @@ func (p *pluginControl) Start() error {
controlLogger.WithFields(log.Fields{
"_block": "start",
}).Info("auto discover path is enabled")
tempDirPath := p.GetTempDir()
controlLogger.WithFields(log.Fields{
"_block": "start",
"tempdirpath": tempDirPath,
}).Info("temporary directory path set")

paths := filepath.SplitList(p.Config.AutoDiscoverPath)
p.SetAutodiscoverPaths(paths)
for _, pa := range paths {
Expand Down Expand Up @@ -396,7 +392,7 @@ func (p *pluginControl) Start() error {
}).Warn("Auto-loading of plugin '", fileName, "' skipped (plugin not executable)")
continue
}
rp, err := core.NewRequestedPlugin(path.Join(fullPath, fileName), tempDirPath, nil)
rp, err := core.NewRequestedPlugin(path.Join(fullPath, fileName), p.GetTempDir(), nil)
if err != nil {
controlLogger.WithFields(log.Fields{
"_block": "start",
Expand Down
13 changes: 13 additions & 0 deletions snapteld.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ func action(ctx *cli.Context) error {
defer file.Close()
log.SetOutput(file)
}

// verify the temDirPath points to existing directory
tempDirPath := cfg.Control.TempDirPath
f, err := os.Stat(tempDirPath)
if err != nil {
log.Fatal(err)
}
if !f.IsDir() {
log.Fatal("temp dir path provided must be a directory")
}

// Because even though github.com/Sirupsen/logrus states that
// 'Logs the event in colors if stdout is a tty, otherwise without colors'
// Seems like this does not work
Expand All @@ -294,6 +305,8 @@ func action(ctx *cli.Context) error {

log.Info("setting log level to: ", l[cfg.LogLevel])

log.Info("setting temp dir path to: ", tempDirPath)

log.Info("Starting snapteld (version: ", gitversion, ")")

// Set Max Processors for snapteld.
Expand Down

0 comments on commit c535438

Please sign in to comment.