Documentation
¶
Index ¶
- func CleanUserDataDir(userDataPath string, warn func(error))
- func DisableJSON()
- func Emit(p Payload)
- func EnableJSON()
- func IsStaleAppShortcutTarget(target string, installRoot string, exeName string) bool
- func PathWithinDir(path string, dir string) bool
- func SetLogFile(path string) error
- func WaitForDirQuiescence(ctx context.Context, lister ProcessLister, dir string, excludePID int) error
- func WaitForProcessToExit(ctx context.Context, pid int) error
- type BrothBuildFile
- type BrothBuildInfo
- type BrothPatch
- type BrothPatchFile
- type BrothUpgradePath
- type BuildFolder
- type ErrorHandler
- type FinishHandler
- type InstallSource
- type Installer
- type InstallerSettings
- type InstallingUpdate
- type Log
- type Multiverse
- type MultiverseParams
- type NoUpdateAvailable
- type Payload
- type ProcessLister
- type Progress
- type ProgressHandler
- type ProgressLabelHandler
- type ReadyToRelaunch
- type RunningProcess
- type SourceHandler
- type UpdateFailed
- type UpdateReady
- type UpdateRequiresElevation
- type UpgradeResult
- type ValidateHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanUserDataDir ¶ added in v1.29.0
CleanUserDataDir removes app-managed components from the user data directory while preserving user data (profiles, preferences, game library).
func DisableJSON ¶ added in v1.0.0
func DisableJSON()
func EnableJSON ¶ added in v1.0.0
func EnableJSON()
func IsStaleAppShortcutTarget ¶ added in v1.31.0
IsStaleAppShortcutTarget returns true if target points directly at a versioned app executable inside installRoot, i.e. matches <installRoot>/app-<version>/<exeName>. Such targets bypass the stable itch-setup launcher and go stale as soon as the app self-updates.
func PathWithinDir ¶ added in v1.31.0
PathWithinDir returns true if path refers to a file or directory strictly inside dir. The comparison is case-insensitive and respects path component boundaries: "C:\\x\\app-26.10.0\\a.exe" is within "C:\\x\\app-26.10.0" but not within "C:\\x\\app-26.1".
func SetLogFile ¶ added in v1.31.0
SetLogFile mirrors every emitted message to path (appending), for callers that can't read our stdout, such as the app after we've re-executed ourselves elevated.
func WaitForDirQuiescence ¶ added in v1.31.0
func WaitForDirQuiescence(ctx context.Context, lister ProcessLister, dir string, excludePID int) error
WaitForDirQuiescence polls until no running process (other than excludePID) holds executables or modules inside dir, or until ctx is done. On timeout it returns an error naming the remaining blockers. Lister errors are logged and retried, bounded by ctx.
func WaitForProcessToExit ¶ added in v1.0.0
WaitForProcessToExit waits for the process with the given PID to exit. It returns nil once the process is gone, or the context's error if the context is cancelled first.
The ReadyToRelaunch message is emitted immediately: the app waits for it before quitting, so it must not depend on us successfully observing the process first.
Types ¶
type BrothBuildFile ¶ added in v1.0.0
type BrothBuildFile struct {
Type itchio.BuildFileType `json:"type"`
SubType itchio.BuildFileSubType `json:"subType"`
Size int64 `json:"size"`
}
type BrothBuildInfo ¶ added in v1.0.0
type BrothBuildInfo struct {
Version string `json:"version"`
Files []*BrothBuildFile `json:"files"`
}
type BrothPatch ¶ added in v1.0.0
type BrothPatch struct {
Version string `json:"version"`
Files []*BrothPatchFile `json:"files"`
}
func (*BrothPatch) FindSubType ¶ added in v1.0.0
func (bp *BrothPatch) FindSubType(subType itchio.BuildFileSubType) *BrothPatchFile
type BrothPatchFile ¶ added in v1.0.0
type BrothPatchFile struct {
SubType itchio.BuildFileSubType `json:"subType"`
Size int64 `json:"size"`
}
type BrothUpgradePath ¶ added in v1.0.0
type BrothUpgradePath struct {
Patches []*BrothPatch `json:"patches"`
}
type BuildFolder ¶ added in v1.0.0
type ErrorHandler ¶
type ErrorHandler func(err error)
type FinishHandler ¶
type FinishHandler func(source InstallSource)
type InstallSource ¶
type InstallSource struct {
Version string
}
type Installer ¶
type Installer struct {
// contains filtered or unexported fields
}
func NewInstaller ¶
func NewInstaller(settings InstallerSettings) *Installer
func (*Installer) CheckUpgrade ¶ added in v1.31.0
func (i *Installer) CheckUpgrade(mv Multiverse) error
CheckUpgrade only compares versions, without writing anything to the install folder. It's the --upgrade behavior when the install folder isn't writable by the current user: an available update is reported as requiring elevation, and a pending ready build isn't promoted either since the promotion rename would fail the same way.
func (*Installer) Install ¶
func (i *Installer) Install(mv Multiverse)
func (*Installer) Upgrade ¶ added in v1.0.0
func (i *Installer) Upgrade(mv Multiverse) (*UpgradeResult, error)
type InstallerSettings ¶
type InstallerSettings struct {
AppName string
Localizer *localize.Localizer
NoFallback bool
OnError ErrorHandler
OnProgressLabel ProgressLabelHandler
OnProgress ProgressHandler
OnFinish FinishHandler
OnSource SourceHandler
}
type InstallingUpdate ¶ added in v1.0.0
type InstallingUpdate struct {
Version string `json:"version"`
}
func (InstallingUpdate) GetType ¶ added in v1.0.0
func (p InstallingUpdate) GetType() string
type Multiverse ¶
type Multiverse interface {
// Called on launch, or when upgrading
GetCurrentVersion() *BuildFolder
// Called when we start patching
MakeStagingFolder() (string, error)
// defer'd at the end of patching
CleanStagingFolder() error
// Record a freshly-patched build as ready
QueueReady(build *BuildFolder) error
// Returns true if we have a ready build pending
HasReadyPending() bool
// Returns true if the ready pending version is 'version'
ReadyPendingIs(version string) bool
// Returns the version of the ready build pending, or "" if none
GetReadyVersion() string
// Re-reads durable state and returns the ready version pending, or
// "" if none. For reporting after long operations, where in-memory
// state may be stale.
ReloadReadyVersion() (string, error)
// Discard the ready build, removing its folder unless it doubles as
// the current version's folder
ClearReady() error
// Make the ready build current.
MakeReadyCurrent() error
// Validates the current build (can be used after heal)
ValidateCurrent() error
// Returns a human-friendly representation of the state of this multiverse
String() string
}
func NewMultiverse ¶
func NewMultiverse(params *MultiverseParams) (Multiverse, error)
type MultiverseParams ¶
type MultiverseParams struct {
// `itch`, `kitch`
AppName string
// on Linux, `~/.itch`
// on Windows, `%LOCALAPPDATA%/itch`
// on macOS, `~/Library/Application Support/itch-setup`
BaseDir string
// If non-empty, this is where we'll store current
// on macOS, this is `~/Applications`
ApplicationsDir string
// This is called with a folder before making it the current version
OnValidate ValidateHandler
}
type NoUpdateAvailable ¶ added in v1.0.0
type NoUpdateAvailable struct{}
func (NoUpdateAvailable) GetType ¶ added in v1.0.0
func (p NoUpdateAvailable) GetType() string
type ProcessLister ¶ added in v1.31.0
type ProcessLister func() ([]RunningProcess, error)
ProcessLister enumerates running processes. Implementations should tolerate processes vanishing mid-enumeration and skip processes they can't inspect (access denied) rather than failing the whole listing.
type Progress ¶ added in v1.0.0
type ProgressHandler ¶
type ProgressHandler func(progress float64)
type ProgressLabelHandler ¶
type ProgressLabelHandler func(label string)
type ReadyToRelaunch ¶ added in v1.0.0
type ReadyToRelaunch struct{}
func (ReadyToRelaunch) GetType ¶ added in v1.0.0
func (p ReadyToRelaunch) GetType() string
type RunningProcess ¶ added in v1.31.0
type RunningProcess struct {
PID int
// Paths holds the absolute path of the process executable and of any
// loaded modules (DLLs). Any of these being inside a version folder
// keeps Windows from renaming that folder.
Paths []string
}
RunningProcess describes a live process and the executable/module paths it holds open, as far as we could determine.
func FindBlockingProcesses ¶ added in v1.31.0
func FindBlockingProcesses(lister ProcessLister, dir string, excludePID int) ([]RunningProcess, error)
FindBlockingProcesses returns the processes (other than excludePID) that hold their executable or a loaded module inside dir.
type SourceHandler ¶
type SourceHandler func(source InstallSource)
type UpdateFailed ¶ added in v1.0.0
type UpdateFailed struct {
Message string `json:"message"`
}
func (UpdateFailed) GetType ¶ added in v1.0.0
func (p UpdateFailed) GetType() string
type UpdateReady ¶ added in v1.0.0
type UpdateReady struct {
Version string `json:"version"`
}
func (UpdateReady) GetType ¶ added in v1.0.0
func (p UpdateReady) GetType() string
type UpdateRequiresElevation ¶ added in v1.31.0
type UpdateRequiresElevation struct {
Version string `json:"version"`
}
An update is available but the install folder isn't writable by the current user; applying it needs an elevated run (--elevate).
func (UpdateRequiresElevation) GetType ¶ added in v1.31.0
func (p UpdateRequiresElevation) GetType() string
type UpgradeResult ¶ added in v1.5.0
type UpgradeResult struct {
DidUpgrade bool
}