-
Notifications
You must be signed in to change notification settings - Fork 4
/
zipproject.go
75 lines (65 loc) · 2.21 KB
/
zipproject.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package cmdinstance
import (
"path"
"github.com/tzapio/tzap/cli/cmd/cmdinstance/zipwalker"
"github.com/tzapio/tzap/cli/cmd/cmdutil/fileevaluator"
"github.com/tzapio/tzap/internal/logging/tl"
"github.com/tzapio/tzap/pkg/project"
"github.com/tzapio/tzap/pkg/types"
)
type ZipProject struct {
projectName project.ProjectName
projectDir project.ProjectDir
baseDir string
embeddingCollection types.DBCollectionInterface[types.Vector]
embeddingsCache types.DBCollectionInterface[string]
filestampsCache types.DBCollectionInterface[int64]
*zipwalker.ZipWalker //GetFiles() @TODO: Refactor to FS interface?
}
func NewLocalZipProject(name, relativeDirInZip, url string) (project.Project, error) {
tl.Logger.Println("URL: ", url)
fileevaluator := fileevaluator.NewWithBasePatterns()
projectDir := project.ProjectDir(path.Join("./.tzap-data", name))
zipwalker := zipwalker.New(fileevaluator, relativeDirInZip, url)
embeddingCollection, err := NewEmbeddingsCollection(projectDir)
if err != nil {
return nil, err
}
embeddingsCache, err := NewEmbeddingsCache(projectDir)
if err != nil {
return nil, err
}
filestampCache, err := NewFilestampCache(projectDir)
if err != nil {
return nil, err
}
zipProject := &ZipProject{
projectName: project.LOCALPROJECTNAME,
baseDir: relativeDirInZip,
projectDir: projectDir,
embeddingCollection: embeddingCollection,
embeddingsCache: embeddingsCache,
filestampsCache: filestampCache,
ZipWalker: zipwalker,
}
return zipProject, nil
}
func (l *ZipProject) CanIndex() bool {
return true
}
// GetEmbeddingsCache implements project.Project
func (l *ZipProject) GetEmbeddingsCache() types.DBCollectionInterface[string] {
return l.embeddingsCache
}
// GetTimestampCache implements project.Project
func (l *ZipProject) GetTimestampCache() types.DBCollectionInterface[int64] {
return l.filestampsCache
}
// GetEmbedding implements project.Project
func (l *ZipProject) GetEmbeddingCollection() types.DBCollectionInterface[types.Vector] {
return l.embeddingCollection
}
// GetProjectName implements project.Project
func (l *ZipProject) GetProjectName() project.ProjectName {
return l.projectName
}