address PR feedback

This commit is contained in:
Fabian Jakobs 2024-09-17 11:21:15 +02:00
parent 84d1bbf2d5
commit 6bf59ff981
No known key found for this signature in database
2 changed files with 4 additions and 12 deletions

View File

@ -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 {
@ -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
}

View File

@ -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