mirror of https://github.com/databricks/cli.git
Error when file does not exist
This commit is contained in:
parent
c9340d6317
commit
c98671a08b
|
@ -3,7 +3,6 @@ package mutator
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -35,10 +34,6 @@ func (m *translateNotebookPaths) rewritePath(b *bundle.Bundle, p *string) error
|
||||||
absPath := filepath.Join(b.Config.Path, relPath)
|
absPath := filepath.Join(b.Config.Path, relPath)
|
||||||
nb, _, err := notebook.Detect(absPath)
|
nb, _, err := notebook.Detect(absPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Ignore if this file doesn't exist. Maybe it's an absolute workspace path?
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("unable to determine if %s is a notebook: %w", relPath, err)
|
return fmt.Errorf("unable to determine if %s is a notebook: %w", relPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package notebook
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -39,6 +41,10 @@ func readHeader(path string) ([]byte, error) {
|
||||||
func Detect(path string) (notebook bool, language workspace.Language, err error) {
|
func Detect(path string) (notebook bool, language workspace.Language, err error) {
|
||||||
header := ""
|
header := ""
|
||||||
|
|
||||||
|
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
|
||||||
|
return false, "", fmt.Errorf("file %s does not exist", path)
|
||||||
|
}
|
||||||
|
|
||||||
// Determine which header to expect based on filename extension.
|
// Determine which header to expect based on filename extension.
|
||||||
ext := strings.ToLower(filepath.Ext(path))
|
ext := strings.ToLower(filepath.Ext(path))
|
||||||
switch ext {
|
switch ext {
|
||||||
|
|
Loading…
Reference in New Issue