Documentation
¶
Overview ¶
Package reset puts a server back the way it was first installed, or back to a copy kept by an earlier reset. A running server has its files open, so asking and doing are apart: a request is written, and the next start carries it out, before anything opens the database.
Only what is inside the server's own folders is touched, never a library's files.
Index ¶
- Constants
- func Ask(data string, r Request) error
- func AskRepair(data string, r RepairRequest) error
- func Cancel(data string) (bool, error)
- func CancelRepair(data string) error
- func Check(f Folders, libraries []string) (outside []string, err error)
- func DeleteCopy(data, name string) error
- func NewRepairStage(data string, at time.Time) (name string, err error)
- type Copy
- type Folders
- type RepairRequest
- type RepairResult
- type Request
- type Result
Constants ¶
const ( ModeKeepCopy = "keep-copy" // everything moves into a copy inside the data folder ModeDelete = "delete" // everything goes for good, earlier copies too ModeRestore = "restore" // a copy comes back; what's there now becomes a new copy )
What a request does. Modes other than these are refused.
Variables ¶
This section is empty.
Functions ¶
func AskRepair ¶
func AskRepair(data string, r RepairRequest) error
AskRepair writes the request for the next start.
func CancelRepair ¶
CancelRepair takes back a waiting repair, and removes what was built for it.
func Check ¶
Check says whether this install can be reset as it's set up, and which folders set elsewhere can go with it. Anyone's media inside the data folder, or the program itself, stops it: those aren't the server's to move.
func DeleteCopy ¶
DeleteCopy removes one kept copy for good.
Types ¶
type Folders ¶
type Folders struct {
Data string
Others []string // cache, transcode and artwork folders, which may be set elsewhere
Program string
Config string // the config file, which stays
}
Folders are the places a server keeps its own things.
type RepairRequest ¶
type RepairRequest struct {
Stage string `json:"stage"` // the folder in the data folder holding the new wms.db
KeepIn string `json:"keepIn"` // the folder in the data folder the old files move to
At time.Time `json:"at"`
}
RepairRequest is a new database waiting to replace the one in use.
func PendingRepair ¶
func PendingRepair(data string) *RepairRequest
PendingRepair is the request waiting, or nil.
type RepairResult ¶
type RepairResult struct {
OK bool `json:"ok"`
Kept string `json:"kept,omitempty"`
Error string `json:"error,omitempty"`
At time.Time `json:"at"`
}
RepairResult says how the last one went.
func ApplyRepair ¶
func ApplyRepair(data string) *RepairResult
ApplyRepair carries out a waiting repair, if there is one, and returns nil if there wasn't. Nothing else may have the database open. If anything can't move, every file goes back where it was and the old database stays in use.
func LastRepair ¶
func LastRepair(data string) *RepairResult
LastRepair says how the last one went, or nil.
type Request ¶
type Request struct {
Mode string `json:"mode"`
Copy string `json:"copy"` // the copy to make, or for restore the one to bring back
Save string `json:"save,omitempty"` // restore: the copy to make of what's there now
Outside []string `json:"outside,omitempty"` // folders set elsewhere to clear
At time.Time `json:"at"`
}
Request is what the next start is to do.
type Result ¶
type Result struct {
OK bool `json:"ok"`
Mode string `json:"mode"`
Copy string `json:"copy,omitempty"`
Error string `json:"error,omitempty"`
Notes []string `json:"notes,omitempty"`
At time.Time `json:"at"`
}
Result is how the last one went.