Skip to content

Commit 01a7e6b

Browse files
committed
[validate] Provide invalid BIDS root error
Closes #107 Provide the appropriate error when the BIDS validator is not run from the root BIDS folder structure.
1 parent 3c14ab0 commit 01a7e6b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

internal/web/validate.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ func handleValidationConfig(cfgpath string) (Validationcfg, error) {
7777
// and saves the results to the appropriate document for later viewing.
7878
func validateBIDS(valroot, resdir string) error {
7979
srvcfg := config.Read()
80-
// Use validation config file if available
8180
var validateNifti bool
8281

82+
// Use validation config file if available
8383
cfgpath := filepath.Join(valroot, srvcfg.Label.ValidationConfigFile)
8484
log.ShowWrite("[Info] looking for config file at %q", cfgpath)
8585
if fi, err := os.Stat(cfgpath); err == nil && !fi.IsDir() {
@@ -118,17 +118,19 @@ func validateBIDS(valroot, resdir string) error {
118118
serr.Reset()
119119
cmd.Stdout = &out
120120
cmd.Stderr = &serr
121-
// cmd.Dir = tmpdir
122-
if err := cmd.Run(); err != nil {
123-
return fmt.Errorf("[Error] running bids validation (%s): %q, %q", valroot, err.Error(), serr.String())
121+
err := cmd.Run()
122+
// Only return if the error is not related to the bids validation; if the out string contains information
123+
// we can continue
124+
if err != nil && !strings.Contains(out.String(), "QUICK_VALIDATION_FAILED") {
125+
return fmt.Errorf("[Error] running bids validation (%s): %q, %q, %q", valroot, err.Error(), serr.String(), out.String())
124126
}
125127

126128
// We need this for both the writing of the result and the badge
127129
output := out.Bytes()
128130

129131
// CHECK: can this lead to a race condition, if a job for the same user/repo combination is started twice in short succession?
130132
outFile := filepath.Join(resdir, srvcfg.Label.ResultsFile)
131-
err := ioutil.WriteFile(outFile, []byte(output), os.ModePerm)
133+
err = ioutil.WriteFile(outFile, []byte(output), os.ModePerm)
132134
if err != nil {
133135
return fmt.Errorf("[Error] writing results file for %q", valroot)
134136
}

0 commit comments

Comments
 (0)