Fix/dagger edit: wrong dir Path leads to infinite loop

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville
2021-09-26 20:50:37 +02:00
parent 2249eab15d
commit a7ca7e11ba
3 changed files with 7 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
@@ -113,6 +114,10 @@ func (dir dirInput) Compile(_ string, state *State) (*compiler.Value, error) {
if !strings.HasPrefix(p, state.Project) {
return nil, fmt.Errorf("%q is outside the project", dir.Path)
}
// Check that directory exists
if _, err := os.Stat(p); os.IsNotExist(err) {
return nil, fmt.Errorf("%q dir doesn't exist", dir.Path)
}
llb := fmt.Sprintf(
`#up: [{do:"local",dir:"%s", include:%s, exclude:%s}]`,