Skip to content

Commit afa137b

Browse files
committed
wip: bundle.NewBatchFromRawContent
1 parent d8776ec commit afa137b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

bundle/bundle.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package bundle
1818

1919
import (
2020
"context"
21+
"fmt"
2122

2223
"github.com/rs/zerolog"
2324

@@ -134,6 +135,25 @@ func NewBatch(documents map[string]deepcode.BundleFile) *Batch {
134135
}
135136
}
136137

138+
func NewBatchFromRawContent(documents map[string][]byte) *Batch {
139+
bundleFiles := make(map[string]deepcode.BundleFile)
140+
141+
for key, rawData := range documents {
142+
bundleFile, err := deepcode.BundleFileFrom(rawData)
143+
if err != nil {
144+
// TODO: logging the error
145+
fmt.Printf("error creating a bundle from the file")
146+
continue
147+
}
148+
149+
bundleFiles[key] = bundleFile
150+
}
151+
152+
return &Batch{
153+
documents: bundleFiles,
154+
}
155+
}
156+
137157
// todo simplify the size computation
138158
// maybe consider an addFile / canFitFile interface with proper error handling
139159
func (b *Batch) canFitFile(uri string, content []byte) bool {

0 commit comments

Comments
 (0)