mirror of
https://github.com/get-drexa/drive.git
synced 2026-02-02 20:01:16 +00:00
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package virtualfs
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/get-drexa/drexa/internal/blob"
|
|
"github.com/google/uuid"
|
|
"github.com/uptrace/bun"
|
|
)
|
|
|
|
type BlobKeyResolver interface {
|
|
// ShouldPersistKey returns true if the resolved key should be stored in node.BlobKey.
|
|
// Flat keys (e.g. UUIDs) return true - key is generated once and stored.
|
|
// Hierarchical keys return false - key is derived from path each time.
|
|
ShouldPersistKey() bool
|
|
Resolve(ctx context.Context, db bun.IDB, node *Node) (blob.Key, error)
|
|
ResolveDeletionKeys(ctx context.Context, node *Node, allKeys []blob.Key) (*DeletionPlan, error)
|
|
|
|
// ResolveBulkMoveOps returns blob move operations for nodes being moved to a new parent.
|
|
// Returns ErrBulkMoveRequiresSameParent if nodes don't all share the same parent.
|
|
// Returns nil, nil if no blob moves are needed (e.g., flat key storage where keys are UUIDs).
|
|
ResolveBulkMoveOps(ctx context.Context, db bun.IDB, nodes []*Node, newParentID uuid.UUID) ([]BlobMoveOp, error)
|
|
}
|
|
|
|
type DeletionPlan struct {
|
|
Prefix blob.Key
|
|
Keys []blob.Key
|
|
}
|
|
|
|
// BlobMoveOp represents a blob move operation from OldKey to NewKey.
|
|
type BlobMoveOp struct {
|
|
Node *Node
|
|
OldKey blob.Key
|
|
NewKey blob.Key
|
|
}
|