linker

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanStaleStoreTmp

func CleanStaleStoreTmp(storeTmpDir string)

CleanStaleStoreTmp removes leftover temp directories in store/tmp/. Only removes entries matching the current PID or entries older than 1 hour.

func CleanStaleVendorDirs

func CleanStaleVendorDirs(projectDir string)

CleanStaleVendorDirs removes leftover vendor.allegro.old/ and vendor.allegro.tmp/.

func CreateTempDir

func CreateTempDir(storeTmpDir string) (string, error)

CreateTempDir creates a process-unique temp directory in store/tmp/.

func DetectStrategy

func DetectStrategy(storeDir, projectDir, forcedStrategy string) (Strategy, Linker)

DetectStrategy probes the filesystem to determine the best link strategy. If forcedStrategy is non-empty, returns it directly (skipping probe).

func ParsePIDFromTmpName

func ParsePIDFromTmpName(name string) (int, bool)

ParsePIDFromTmpName extracts PID from a tmp-{pid}-{random} directory name.

func TryReflink(src, dst string) bool

TryReflink attempts a reflink and returns whether it succeeded.

func WriteVendorState

func WriteVendorState(vendorDir string, opts WriteVendorStateOpts) error

WriteVendorState writes vendor/.allegro-state.json with all Phase 2 fields.

Types

type CopyLinker

type CopyLinker struct{}

CopyLinker links files by copying content.

func (*CopyLinker) LinkFile

func (c *CopyLinker) LinkFile(src, dst string) error

type FileLock

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

FileLock represents an advisory file lock on the project directory.

func AcquireLock

func AcquireLock(ctx context.Context, projectDir string) (*FileLock, error)

AcquireLock creates/opens the lock file and acquires an exclusive flock. Respects context cancellation. Returns error if lock cannot be acquired within 30 seconds.

func (*FileLock) Release

func (fl *FileLock) Release() error

Release releases the file lock. The lock file is NOT deleted.

type HardLinker

type HardLinker struct{}

HardLinker links files via os.Link (hardlink).

func (*HardLinker) LinkFile

func (h *HardLinker) LinkFile(src, dst string) error

type Linker

type Linker interface {
	LinkFile(src, dst string) error
}

Linker is the interface for linking files from CAS to vendor.

type ReflinkLinker

type ReflinkLinker struct{}

ReflinkLinker links files via FICLONE ioctl on Linux (Btrfs/XFS).

func (*ReflinkLinker) LinkFile

func (r *ReflinkLinker) LinkFile(src, dst string) error

type Strategy

type Strategy int

Strategy represents the link method used.

const (
	Reflink Strategy = iota
	Hardlink
	Copy
)

func FormatStrategy

func FormatStrategy(s string) Strategy

FormatStrategy converts a string to Strategy enum.

func (Strategy) String

func (s Strategy) String() string

type VendorState

type VendorState struct {
	AllegroVersion  string            `json:"allegro_version"`
	SchemaVersion   int               `json:"schema_version,omitempty"`
	LinkStrategy    string            `json:"link_strategy"`
	LockHash        string            `json:"lock_hash"`
	InstalledAt     time.Time         `json:"installed_at"`
	Dev             bool              `json:"dev"`
	DevPackages     []string          `json:"dev_packages"`
	ScriptsExecuted bool              `json:"scripts_executed"`
	Packages        map[string]string `json:"packages"`
	PluginPackages  []string          `json:"plugin_packages,omitempty"`
}

VendorState represents vendor/.allegro-state.json.

func ReadVendorState

func ReadVendorState(vendorDir string) (*VendorState, error)

ReadVendorState reads vendor/.allegro-state.json.

func (*VendorState) EffectiveDev

func (s *VendorState) EffectiveDev() bool

EffectiveDev returns the dev mode from state, treating absent as true (Phase 1 default).

func (*VendorState) HasDevPackages

func (s *VendorState) HasDevPackages() bool

HasDevPackages returns true if dev_packages info is available for incremental diff.

func (*VendorState) NeedsFullRebuildForDevSwitch

func (s *VendorState) NeedsFullRebuildForDevSwitch(currentDev bool) bool

NeedsFullRebuildForDevSwitch returns true if switching dev mode requires a full rebuild because dev_packages info is missing (Phase 1 state).

type WriteVendorStateOpts

type WriteVendorStateOpts struct {
	Version         string
	Strategy        Strategy
	LockHash        string
	Packages        map[string]string
	Dev             bool
	DevPackages     []string
	ScriptsExecuted bool
	PluginPackages  []string
}

WriteVendorState writes vendor/.allegro-state.json. WriteVendorStateOpts holds all options for writing the vendor state file.

Jump to

Keyboard shortcuts

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