feat: support bulk file move in same dir

This commit is contained in:
2025-12-13 19:24:54 +00:00
parent 085bbd4ffe
commit 918b85dfd5
7 changed files with 227 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"github.com/get-drexa/drexa/internal/blob"
"github.com/google/uuid"
"github.com/uptrace/bun"
)
@@ -14,9 +15,20 @@ type BlobKeyResolver interface {
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 {
OldKey blob.Key
NewKey blob.Key
}