output

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package output owns native resumable receive output, task locking, journal persistence, compatible-name mapping, and recovery inventory.

Index

Constants

View Source
const (
	MaxPortableNameBytes     = 255
	MaxNameRepairAttempts    = 16
	MaxNameMappings          = 65_536
	MaxNameAdjustmentSamples = 20
)
View Source
const (
	// SmallFileThreshold separates single-shot small files (0 per-file fsync on
	// the hot path; batched journal sync) from large files that stream range
	// checkpoints to disk during transfer.
	SmallFileThreshold   uint64 = 8 << 20 // 8 MiB
	LargeCheckpointBytes uint64 = 8 << 20 // 8 MiB
	// LargeCheckpointInterval caps checkpoint lag during slow trickle writes
	// without spawning background idle timers; it is checked passively in Accept
	// while Pause and Commit flush any remaining bytes on stall, stop, or finish.
	LargeCheckpointInterval = 2 * time.Second
)
View Source
const (
	// ControlDirName holds all private WindShare receive state inside the
	// destination container so user output trees stay clean.
	ControlDirName = ".windshare-tmp"
)

Variables

View Source
var (
	ErrOutOfRange         = errors.New("osfs: range write is out of bounds or overlaps")
	ErrPathEscape         = errors.New("osfs: path escapes output root")
	ErrShareStopped       = errors.New("retained output belongs to a stopped share")
	ErrBusy               = errors.New("retained output operation is currently active")
	ErrAlreadyRunning     = errors.New("matching output operation is already running")
	ErrAmbiguous          = errors.New("matching output operation ownership is ambiguous")
	ErrOperationChanged   = errors.New("retained output operation no longer matches")
	ErrInvalidContract    = errors.New("native recovery contract is invalid")
	ErrUnsafeNamespace    = errors.New("osfs: output namespace is unsafe")
	ErrNamespaceCollision = errors.New("osfs: output namespace entry already exists")
	ErrNameRejected       = errors.New("osfs: destination rejects the output name")
	ErrNamespaceLockBusy  = errors.New("osfs: output namespace lock is already held")
	ErrUnsupportedOutput  = errors.New("osfs: recoverable native output is unsupported by the destination")
)
View Source
var ErrInvalidNameMapping = errors.New("output name mapping is invalid")

Functions

func DiagnoseFailure

func DiagnoseFailure(stage FailureStage, cause error) error

func FailureForStage

func FailureForStage(cause error, stage FailureStage) error

FailureForStage extracts causes owned by one failure stage from an error tree. A FailureClose boundary claims every cause inside it so release failures stay separate from earlier operation failures.

func OpenContainer

func OpenContainer(path string, create bool) (*Dir, RootDisposition, error)

OpenContainer opens an existing destination directory (following a final symlink/junction once through the kernel) or creates it when create is true.

func PortableName

func PortableName(name string) bool

PortableName reports whether name is safe across Windows, macOS, and Linux filesystems. Original source names are attempted natively first; PortableName governs generated repair names and fast-path checks.

func SanitizeCandidate

func SanitizeCandidate(operationID []byte, logicalPath string, attempt uint32) (string, error)

SanitizeCandidate builds a deterministic cross-platform filename while keeping a readable stem and safe extension.

func ValidComponent

func ValidComponent(name string) error

Types

type ActiveLookup

type ActiveLookup struct {
	// contains filtered or unexported fields
}

func (ActiveLookup) Attention

func (l ActiveLookup) Attention() AttentionReason

func (ActiveLookup) Kind

func (l ActiveLookup) Kind() LookupKind

func (ActiveLookup) Operation

func (l ActiveLookup) Operation() *Operation

type AttentionError

type AttentionError struct {
	Reason AttentionReason
}

AttentionError preserves the attention reason when CreateOperation re-checks an automatic selection and encounters a damaged existing operation.

func (*AttentionError) Error

func (err *AttentionError) Error() string

type AttentionReason

type AttentionReason string
const (
	AttentionNone        AttentionReason = ""
	AttentionDestination AttentionReason = "destination-ownership-unknown"
	AttentionRegistry    AttentionReason = "registry-ownership-unknown"
	AttentionLease       AttentionReason = "lease-ownership-unknown"
	AttentionOperation   AttentionReason = "operation-ownership-unknown"
	AttentionCleanup     AttentionReason = "cleanup-uncertain"
)

func (AttentionReason) Valid

func (reason AttentionReason) Valid() bool

type Authority

type Authority struct {
	// contains filtered or unexported fields
}

Authority owns one caller-selected destination container across destination binding, operation lookup/creation, and active receive session lifecycle.

func New

func New(cfg Config) (*Authority, error)

func (*Authority) BindDestination

func (a *Authority) BindDestination(ctx context.Context) (resultErr error)

func (*Authority) Close

func (a *Authority) Close() error

func (*Authority) CreateOperation

func (a *Authority) CreateOperation(
	ctx context.Context,
	lookup ActiveLookup,
	artifact receivecontract.ArtifactSpec,
) (_ *Operation, resultErr error)

func (*Authority) OpenOperation

func (a *Authority) OpenOperation(ctx context.Context, op *Operation) (transfer.DirectTreeSession, error)

func (*Authority) SelectOperation

func (a *Authority) SelectOperation(
	ctx context.Context,
	selection transfer.SelectionSpec,
	selector receivecontract.OperationSelection,
) (result ActiveLookup, resultErr error)

type Config

type Config struct {
	RootPath    string
	CreateRoot  bool
	Diagnostics diagnostics.Sink
}

type DestinationCapabilities

type DestinationCapabilities struct {
	SafePublish             bool
	SafePublishReason       string
	OperationRecovery       bool
	OperationRecoveryReason string
	// contains filtered or unexported fields
}

DestinationCapabilities reports whether the destination supports atomic no-replace publication required for safe resumable downloads.

func ProbeDestination

func ProbeDestination(root *Dir) (caps DestinationCapabilities, resultErr error)

ProbeDestination verifies that the destination filesystem supports atomic no-replace file publication using a temporary scratch directory that is removed before returning.

func (DestinationCapabilities) Valid

func (c DestinationCapabilities) Valid() bool

func (DestinationCapabilities) ValidateSupport

func (c DestinationCapabilities) ValidateSupport() error

type Diagnostic

type Diagnostic struct {
	Stage            FailureStage
	NativeErrorClass NativeErrorClass
	Fault            transferfault.Fault
}

Diagnostic is value-only native failure evidence extracted at adapter edges.

func DiagnosticFor

func DiagnosticFor(err error) (Diagnostic, bool)

func (Diagnostic) Valid

func (diagnostic Diagnostic) Valid() bool

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir is an open, verified directory handle that pins the directory without repeatedly opening and closing os.Root on every child syscall.

func (*Dir) Close

func (d *Dir) Close() error

func (*Dir) Path

func (d *Dir) Path() string

func (*Dir) SameDirectory

func (d *Dir) SameDirectory(other *Dir) bool

func (*Dir) Sync

func (d *Dir) Sync() error

type DirLock

type DirLock struct {
	// contains filtered or unexported fields
}

DirLock holds an exclusive destination-scoped OS coordination lock anchored to the destination container itself rather than a file inside .windshare-tmp, allowing .windshare-tmp to be created and removed while locked. Callers must release a DirLock on the same goroutine that acquired it.

func (*DirLock) Close

func (l *DirLock) Close() error

type EntryKind

type EntryKind uint8
const (
	EntryAbsent EntryKind = iota
	EntryRegularFile
	EntryDirectory
	EntryOther
)

type FailureStage

type FailureStage uint8
const (
	FailureDestinationBinding FailureStage = iota + 1
	FailureInventory
	FailureLookup
	FailureOpen
	FailureCreate
	FailureCheckpoint
	FailureDurability
	FailureClose
)

func (FailureStage) String

func (stage FailureStage) String() string

func (FailureStage) Valid

func (stage FailureStage) Valid() bool

type FileLock

type FileLock struct {
	// contains filtered or unexported fields
}

FileLock holds a non-blocking exclusive OS-level task file lock (flock / LockFileEx).

func (*FileLock) Close

func (l *FileLock) Close() error

type LookupKind

type LookupKind uint8
const (
	LookupCreateReady LookupKind = iota + 1
	LookupNotFound
	LookupReopened
	LookupAlreadyRunning
	LookupNeedsAttention
	LookupAmbiguous
)

type NameAdjustment

type NameAdjustment struct {
	LogicalPath  string
	PhysicalPath string
}

NameAdjustment records one logical name or path saved under a compatible physical spelling: relative to the destination directory for nested items, or the destination entry name itself when the top-level root or single file was repaired.

type NameAdjustmentSummary

type NameAdjustmentSummary struct {
	Count   uint64
	Samples []NameAdjustment
}

NameAdjustmentSummary is a bounded value snapshot of compatible-name repairs materialized by an operation. Count is exact; Samples is capped.

func (NameAdjustmentSummary) Clone

type NameMapping

type NameMapping struct {
	LogicalPath       string `json:"logical"`
	PhysicalComponent string `json:"physical"`
	Attempt           uint32 `json:"attempt"`
	Directory         bool   `json:"dir,omitempty"`
}

NameMapping persists one logical-to-physical component repair so restarts reuse the exact same destination spelling.

type NativeErrorClass

type NativeErrorClass uint8
const (
	NativeErrorAccessDenied NativeErrorClass = iota + 1
	NativeErrorSharingViolation
	NativeErrorNotFound
	NativeErrorInvalidHandle
	NativeErrorUnsupported
	NativeErrorIO
	NativeErrorUnknown
)

func ClassifyNativeError

func ClassifyNativeError(err error) (NativeErrorClass, bool)

ClassifyNativeError maps an underlying OS error into a closed diagnostic class so higher layers can present bounded guidance without leaking host paths.

func (NativeErrorClass) String

func (class NativeErrorClass) String() string

func (NativeErrorClass) Valid

func (class NativeErrorClass) Valid() bool

type Operation

type Operation struct {
	// contains filtered or unexported fields
}

Operation owns an active task lock, journal, and top-level destination root for one receive intent.

func (*Operation) Discard

func (op *Operation) Discard(ctx context.Context) error

func (*Operation) Idle

func (op *Operation) Idle() bool

func (*Operation) NameAdjustments

func (op *Operation) NameAdjustments() NameAdjustmentSummary

func (*Operation) ReceiveIntent

func (op *Operation) ReceiveIntent() (transfer.ReceiveIntent, bool)

func (*Operation) RecordShareStopped

func (op *Operation) RecordShareStopped(ctx context.Context) error

type RecoveryInventory

type RecoveryInventory struct {
	// contains filtered or unexported fields
}

func ListOperations

func ListOperations(ctx context.Context, rootPath string) (RecoveryInventory, error)

ListOperations inspects retained native operations under <rootPath>/.windshare-tmp without creating or modifying anything when no control directory exists.

func (RecoveryInventory) Status

func (RecoveryInventory) Summaries

func (inv RecoveryInventory) Summaries() []RecoverySummary

func (RecoveryInventory) UnknownEntries

func (inv RecoveryInventory) UnknownEntries() bool

type RecoveryItem

type RecoveryItem struct {
	// contains filtered or unexported fields
}

func (RecoveryItem) BlockReason

func (i RecoveryItem) BlockReason() RecoveryItemBlockReason

func (RecoveryItem) CanonicalPath

func (i RecoveryItem) CanonicalPath() string

func (RecoveryItem) Reference

func (i RecoveryItem) Reference() string

func (RecoveryItem) State

func (i RecoveryItem) State() RecoveryItemState

type RecoveryItemBlockReason

type RecoveryItemBlockReason uint8
const (
	RecoveryItemBlockNone RecoveryItemBlockReason = iota
	RecoveryItemBlockPublicationUnknown
	RecoveryItemBlockCheckpointInvalid
	RecoveryItemBlockOwnedObjectUnknown
	RecoveryItemBlockRevisionConflict
)

type RecoveryItemState

type RecoveryItemState uint8
const (
	RecoveryItemIncomplete RecoveryItemState = iota + 1
	RecoveryItemResumable
	RecoveryItemPublished
	RecoveryItemFailed
	RecoveryItemBlocked
)

type RecoveryListStatus

type RecoveryListStatus uint8
const (
	RecoveryListReady RecoveryListStatus = iota + 1
	RecoveryListNeedsAttention
)

type RecoveryOperationState

type RecoveryOperationState uint8
const (
	RecoveryOperationIncomplete RecoveryOperationState = iota + 1
	RecoveryOperationResumable
	RecoveryOperationShareStopped
	RecoveryOperationCleanupPending
	RecoveryOperationNeedsAttention
	RecoveryOperationDiscarded
)

type RecoverySummary

type RecoverySummary struct {
	// contains filtered or unexported fields
}

func DiscardOperation

func DiscardOperation(
	ctx context.Context,
	rootPath string,
	opID receivecontract.OperationID,
) (summary RecoverySummary, resultErr error)

DiscardOperation deletes WindShare's private scratch directory for opID while preserving every published and foreign file in the user's destination.

func (RecoverySummary) Busy

func (s RecoverySummary) Busy() bool

func (RecoverySummary) Items

func (s RecoverySummary) Items() []RecoveryItem

func (RecoverySummary) NeedsAttentionReason

func (s RecoverySummary) NeedsAttentionReason() AttentionReason

func (RecoverySummary) OperationID

func (RecoverySummary) ReceiveIntentDigest

func (s RecoverySummary) ReceiveIntentDigest() transfer.ReceiveIntentDigest

func (RecoverySummary) State

func (RecoverySummary) StateGeneration

func (s RecoverySummary) StateGeneration() uint64

func (RecoverySummary) Valid

func (s RecoverySummary) Valid() bool

type RootDisposition

type RootDisposition uint8
const (
	CallerProvidedContainer RootDisposition = iota + 1
	AuthorityCreatedRoot
)

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session implements transfer.DirectTreeSession and transfer.DeliveryHistory directly over an active Operation's journal and open directory handles.

Session entry points serialize state transitions and shared directory handle lifetimes under s.mu (order: tx.mu -> s.mu -> nameMapper.mu -> journal.mu), while per-file data writes and publication run independently under tx.mu.

func (*Session) AdmitDirectory

func (*Session) BeginFile

func (*Session) Capabilities

func (s *Session) Capabilities() transfer.DirectTreeCapabilities

func (*Session) FinalizeDirectory

func (s *Session) FinalizeDirectory(
	ctx context.Context,
	admission transfer.DirectoryAdmission,
) (transfer.DirectorySettlement, error)

func (*Session) FinalizeTree

func (*Session) LookupDelivery

func (s *Session) LookupDelivery(
	ctx context.Context,
	fileID catalog.FileID,
	materializationRelativePath string,
) (transfer.HistoricalDelivery, bool, error)

func (*Session) PauseTree

func (*Session) SessionID

func (s *Session) SessionID() transfer.OutputSessionID

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL