Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"pageswiki/internal/geduldh"
|
|
)
|
|
|
|
// MaterializeDocument supplies a verified node-local, read-only scratch copy
|
|
// for tools needing a pathname. Callers must authorize the reference first and
|
|
// close the lease after all subprocesses finish. DB-only legacy stores work too.
|
|
// TMPDIR is the operator-controlled local scratch root, not DocumentRoot.
|
|
func (s *Store) MaterializeDocument(ctx context.Context, hash string, maxBytes int64) (*geduldh.Lease, error) {
|
|
s.documentMaterializerOnce.Do(func() {
|
|
// These fixed safe defaults precede configurable deployment profiles.
|
|
s.documentMaterializer, _ = geduldh.NewMaterializer(documentSource{s}, geduldh.MaterializeOptions{
|
|
MaxBytes: 2 << 30, Concurrent: 2, Timeout: 2 * time.Minute,
|
|
})
|
|
})
|
|
return s.documentMaterializer.Acquire(ctx, hash, maxBytes)
|
|
}
|
|
|
|
type documentSource struct{ store *Store }
|
|
|
|
func (source documentSource) Stat(ctx context.Context, hash string) (geduldh.Info, error) {
|
|
size, err := source.store.DocumentSizeContext(ctx, hash)
|
|
return geduldh.Info{Hash: hash, Size: size}, err
|
|
}
|
|
|
|
func (source documentSource) Open(ctx context.Context, hash string) (geduldh.Reader, error) {
|
|
return source.store.OpenDocumentContext(ctx, hash)
|
|
}
|