reset

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

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

View Source
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 Ask

func Ask(data string, r Request) error

Ask writes a request for the next start. A request already waiting is replaced.

func AskRepair

func AskRepair(data string, r RepairRequest) error

AskRepair writes the request for the next start.

func Cancel

func Cancel(data string) (bool, error)

Cancel takes back a request that hasn't been carried out, and says if there was one.

func CancelRepair

func CancelRepair(data string) error

CancelRepair takes back a waiting repair, and removes what was built for it.

func Check

func Check(f Folders, libraries []string) (outside []string, err error)

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

func DeleteCopy(data, name string) error

DeleteCopy removes one kept copy for good.

func NewRepairStage

func NewRepairStage(data string, at time.Time) (name string, err error)

NewRepairStage makes the folder a new database is built in.

Types

type Copy

type Copy struct {
	Name  string `json:"name"`
	At    int64  `json:"at"`
	Bytes int64  `json:"bytes"`
}

Copy is one kept by an earlier reset.

func Copies

func Copies(data string) []Copy

Copies are those kept in the data folder, newest first.

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.

func Pending

func Pending(data string) *Request

Pending is the request waiting, or nil.

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.

func Apply

func Apply(f Folders) *Result

Apply carries out a waiting request, if there is one. It returns nil when there was none. On failure the install is left as it was, and the server starts as usual.

func Last

func Last(data string) *Result

Last says how the last one went, or nil.

Jump to

Keyboard shortcuts

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