Skip to content

Commit

Permalink
address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fjakobs committed Sep 17, 2024
1 parent 84d1bbf commit 6bf59ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
15 changes: 3 additions & 12 deletions libs/notebook/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ func Detect(name string) (notebook bool, language workspace.Language, err error)
}

type inMemoryFile struct {
content []byte
readIndex int64
buffer bytes.Buffer
}

type inMemoryFS struct {
Expand All @@ -158,20 +157,12 @@ func (f *inMemoryFile) Stat() (fs.FileInfo, error) {
}

func (f *inMemoryFile) Read(b []byte) (n int, err error) {
if f.readIndex >= int64(len(f.content)) {
err = io.EOF
return
}

n = copy(b, f.content[f.readIndex:])
f.readIndex += int64(n)
return
return f.buffer.Read(b)
}

func (fs inMemoryFS) Open(name string) (fs.File, error) {
return &inMemoryFile{
content: fs.content,
readIndex: 0,
buffer: *bytes.NewBuffer(fs.content),
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions libs/template/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (r *renderer) computeFile(relPathTemplate string) (file, error) {
return nil, err
}

// we need the absolute path in case we need to write notebooks using the REST API
rootPath, err := filepath.Abs(r.instanceRoot)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6bf59ff

Please sign in to comment.