wip: vfs implementation

This commit is contained in:
2025-11-27 20:49:58 +00:00
parent c0e2f7ff37
commit b1e34f878c
9 changed files with 466 additions and 36 deletions

View File

@@ -0,0 +1,38 @@
package virtualfs
import (
"context"
"github.com/get-drexa/drexa/internal/blob"
"github.com/google/uuid"
"github.com/uptrace/bun"
)
type BlobKeyResolver interface {
Resolve(ctx context.Context, node *Node) (blob.Key, error)
}
type FlatKeyResolver struct{}
func (r *FlatKeyResolver) Resolve(ctx context.Context, node *Node) (blob.Key, error) {
if node.BlobKey == "" {
id, err := uuid.NewV7()
if err != nil {
return "", err
}
return blob.Key(id.String()), nil
}
return node.BlobKey, nil
}
type HierarchicalKeyResolver struct {
db *bun.DB
}
func (r *HierarchicalKeyResolver) Resolve(ctx context.Context, node *Node) (blob.Key, error) {
path, err := buildNodeAbsolutePath(ctx, r.db, node.ID)
if err != nil {
return "", err
}
return blob.Key(path), nil
}