+25
-0
lines changedFilter options
+25
-0
lines changed Original file line number Diff line number Diff line change
@@ -217,6 +217,19 @@ func validateEnum(s string, candidates []string) error {
217
217
return nil
218
218
}
219
219
220
+
func validateDirectory(s string) error {
221
+
fi, err := os.Stat(s)
222
+
if err != nil {
223
+
return err
224
+
}
225
+
226
+
if !fi.IsDir() {
227
+
return fmt.Errorf("not a directory")
228
+
}
229
+
230
+
return nil
231
+
}
232
+
220
233
func parseCli(args []string) (options, []string, error) {
221
234
var format, purgeKeep, purgeInterval string
222
235
@@ -391,6 +404,12 @@ func parseCli(args []string) (options, []string, error) {
391
404
return opts, changed, fmt.Errorf("options --encrypt and --decrypt are mutually exclusive")
392
405
}
393
406
407
+
if opts.BinDirectory != "" {
408
+
if err := validateDirectory(opts.BinDirectory); err != nil {
409
+
return opts, changed, fmt.Errorf("bin directory (-B) must be an existing directory")
410
+
}
411
+
}
412
+
394
413
// Validate upload option
395
414
stores := []string{"none", "s3", "sftp", "gcs", "azure"}
396
415
if err := validateEnum(opts.Upload, stores); err != nil {
@@ -583,6 +602,12 @@ func loadConfigurationFile(path string) (options, error) {
583
602
}
584
603
opts.Format = []rune(format)[0]
585
604
605
+
if opts.BinDirectory != "" {
606
+
if err := validateDirectory(opts.BinDirectory); err != nil {
607
+
return opts, fmt.Errorf("bin_directory must be an existing directory")
608
+
}
609
+
}
610
+
586
611
// Validate upload option
587
612
stores := []string{"none", "s3", "sftp", "gcs", "azure"}
588
613
if err := validateEnum(opts.Upload, stores); err != nil {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4