Skip to content

Commit 68ed3ab

Browse files
authored
Merge pull request #44 from philippgille/fix-path-joining
Fix path joining
2 parents 41e6823 + 8097782 commit 68ed3ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎collection.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"os"
8-
"path"
8+
"path/filepath"
99
"slices"
1010
"sort"
1111
"sync"
@@ -45,14 +45,14 @@ func newCollection(name string, metadata map[string]string, embed EmbeddingFunc,
4545
// Persistence
4646
if dir != "" {
4747
safeName := hash2hex(name)
48-
c.persistDirectory = path.Join(dir, safeName)
48+
c.persistDirectory = filepath.Join(dir, safeName)
4949
// Create dir
5050
err := os.MkdirAll(c.persistDirectory, 0o700)
5151
if err != nil {
5252
return nil, fmt.Errorf("couldn't create collection directory: %w", err)
5353
}
5454
// Persist name and metadata
55-
metadataPath := path.Join(c.persistDirectory, metadataFileName)
55+
metadataPath := filepath.Join(c.persistDirectory, metadataFileName)
5656
pc := struct {
5757
Name string
5858
Metadata map[string]string
@@ -230,7 +230,7 @@ func (c *Collection) AddDocument(ctx context.Context, doc Document) error {
230230
// Persist the document
231231
if c.persistDirectory != "" {
232232
safeID := hash2hex(doc.ID)
233-
filePath := path.Join(c.persistDirectory, safeID)
233+
filePath := filepath.Join(c.persistDirectory, safeID)
234234
err := persist(filePath, doc)
235235
if err != nil {
236236
return fmt.Errorf("couldn't persist document: %w", err)

0 commit comments

Comments
 (0)