From 14a35cdd9e401824d4e16c3e6b8b6deec6c81ebb Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Sun, 21 Nov 2021 16:30:57 +1030 Subject: [PATCH] Check the chosen command for existence --- CHANGELOG.md | 2 ++ config/config.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc294e5..94141ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Check the chosen command exists when configuring a profile + ## [v0.5.3] - 2021-11-21 - Add config option to limit number of simultaneous downloads diff --git a/config/config.go b/config/config.go index 199cdf0..8d3e1d0 100644 --- a/config/config.go +++ b/config/config.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "os" + "os/exec" "strings" "gopkg.in/yaml.v2" @@ -147,6 +148,12 @@ func (c *Config) UpdateFromJSON(j []byte) error { } } + // check the command exists + _, err := exec.LookPath(newConfig.DownloadProfiles[i].Command) + if err != nil { + return fmt.Errorf("Could not find %s on the path", newConfig.DownloadProfiles[i].Command) + } + } *c = newConfig