Documentation
¶
Overview ¶
Package sync brings a server folder in line with a file manifest. It plans first, so the launcher can show what will change and how much it will download, then applies the plan.
Files are never written in place. Each download goes to a temporary file that is checked and then renamed over the old one, so an interrupted update never leaves a half-written file, and a hard link in the folder (see install) is replaced rather than written through. A temporary file left by an interrupted download is carried on from next time, rather than downloaded again.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInUse = errors.New("file is in use; close the game and try again")
ErrInUse means a file couldn't be replaced because something, usually the game, has it open.
Functions ¶
Types ¶
type Action ¶
type Action struct {
Kind Kind `json:"kind"`
File spec.File `json:"file"`
Reason string `json:"reason"`
}
Action is one change to the server folder.
type Cache ¶
type Cache map[string]CacheEntry
Cache remembers file hashes between runs, so an unchanged file isn't rehashed on every start. Entries are trusted only while size and modification time still match.
type CacheEntry ¶
type CacheEntry struct {
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
SHA256 string `json:"sha256"`
}
CacheEntry is what the cache knows about one file.
type Plan ¶
type Plan struct {
Actions []Action `json:"actions"`
// Bytes is the total to download.
Bytes int64 `json:"bytes"`
}
Plan is everything needed to bring a folder up to date.
func PlanManifest ¶
PlanManifest compares the folder with the manifest.
func PlanMatchingRemoval ¶
PlanMatchingRemoval is the cautious form of PlanRemoval, for when the launcher has no record of installing a component but its files may be there, for example from an older layout. Only files that match the manifest exactly, by size and SHA-256, are removed.