From c50e0b7c05bfd1e3bdd7dad82a7c665800baef03 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 4 Sep 2024 13:56:36 +0200 Subject: [PATCH] PR feedback --- libs/template/file.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/template/file.go b/libs/template/file.go index 3f1a3d7238..b26435d985 100644 --- a/libs/template/file.go +++ b/libs/template/file.go @@ -11,6 +11,7 @@ import ( "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/filer" + "github.com/databricks/cli/libs/log" "github.com/databricks/cli/libs/notebook" "github.com/databricks/cli/libs/runtime" "github.com/databricks/databricks-sdk-go/service/workspace" @@ -110,11 +111,14 @@ func (f *inMemoryFile) PersistToDisk() error { func shouldUseImportNotebook(ctx context.Context, path string, content []byte) bool { if strings.HasPrefix(path, "/Workspace/") && runtime.RunsOnDatabricks(ctx) { - isNotebook, _, _ := notebook.DetectWithContent(path, content) - return isNotebook - } else { - return false + isNotebook, _, err := notebook.DetectWithContent(path, content) + if err != nil { + log.Debugf(ctx, "Error detecting notebook: %v", err) + } + return isNotebook && err != nil } + + return false } func writeFile(ctx context.Context, path string, content []byte, perm fs.FileMode) error {