Documentation ¶
Overview ¶
Package store manages the files that are used to hold sure data.
Sure data is stored in a small number of files, referred to as sure files. The features used will determine which of these files is used for a given operation.
The most basic operation is to store the data in a pair of files. These will have names:
2sure.dat.gz 2sure.bak.gz
with .dat.gz representing the most recent scan, and .bak.gz representing the previous one. Earlier scans are discarded. During operation, the store will write to a temporary file 2sure.nn.gz, where nn is an incrementing integer, starting with 0. This is done because it is unsafe to overwrite files as root, and sure is often run as root. The store will use the lowest numbered file that does not exist, and remove it when it is finished. The use of the number prevents failure if a file is somehow left behind.
The options available to the basic store are that the files may or may not be compressed (with or without the .gz suffix), the path that the files should be stored in (a general default is the base of the tree being scanned), and the prefix ("2sure") part of the name.
When the backups are stored as weave files, the same file names are used (the software can tell by reading the files if they are weave format). The primary difference being that the ".dat.gz" file will hold all of the previous versions. The ".bak.gz" is redundant in this case, but one version is kept around for safety. This format is generally more useful to accompany backups, for example, where the backup may have multiple versions stored in it, and these can be kept in the surefile store as well.
In order to write the weave versions, the user must provide one or more tags to distinguish the particular version being written.
Index ¶
- Constants
- type InvalidName
- type NotDir
- type Store
- func (s *Store) BackupFile() string
- func (s *Store) FixTags()
- func (s *Store) GetDelta(num int) (int, error)
- func (s *Store) IsCompressed() bool
- func (s *Store) MainFile() string
- func (s *Store) Parse(name string) error
- func (s *Store) ReadBak() (*sure.Tree, error)
- func (s *Store) ReadDat() (*sure.Tree, error)
- func (s *Store) ReadDelta(num int) (*sure.Tree, error)
- func (s *Store) ReadHeader() (*weave.Header, error)
- func (s *Store) Set(value string) error
- func (s *Store) String() string
- func (s *Store) TempFile(num int, compressed bool) string
- func (s *Store) Type() string
- func (s *Store) Write(tree *sure.Tree) error
- func (s *Store) WriteDelta(tree *sure.Tree, base int) error
- type Tags
Constants ¶
const ( DeltaLatest = -1 // The most recent version. DeltaPrior = -2 // The second to most recent version. )
Magic delta numbers to refer to previous deltas TODO: Interpret these the same as slices in python to be more flexible.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InvalidName ¶
type InvalidName string
InvalidName is an error returned if the name contains an unknown extension.
func (InvalidName) Error ¶
func (n InvalidName) Error() string
type NotDir ¶
type NotDir string
NotDir is an error returned when the name doesn't describe an existing path.
type Store ¶
type Store struct { Path string // The directory where the surefiles will be written. Base string // The initial part of the name. Ext string // The extension to use "normally dat" Plain bool // Plain indicates the files should not be compressed. Tags map[string]string // For delta stores, indicates tags for next delta written. Name string // The name used to describe this capture. }
The Store represents the current surefile store. The default values will result in a the files "./2sure.dat.gz" and the likes being used.
func (*Store) BackupFile ¶
BackupFile returns the name of the backup file.
func (*Store) FixTags ¶
func (s *Store) FixTags()
FixTags adjusts the tags appropriately after any options from the user have been processed. If 'name' is not given, it will have the same value as time. The name will be deleted from the tags, and placed into the Name value in the struct.
func (*Store) GetDelta ¶
GetDelta canonicalizes a delta number. Returns an error if there was no delta to read.
func (*Store) IsCompressed ¶
IsCompressed returns whether or not this store is compressed.
func (*Store) Parse ¶
Parse attempts to determine the parameters of the Store structure based on a user-specified path. The path specified can be the path to a directory. In this case, we will look at possible filenames to determine the other parameters. The path can also give a filename of one of the surefiles, and we will derive the name information from that.
If the error result is nil, the Store will have the parameters set according to user preferences. Otherwise, the error will give details, and the Store will remain unchanged.
func (*Store) ReadBak ¶
ReadBak reads a tree from the backup file.
func (*Store) ReadDat ¶
ReadDat reads a tree from the data file.
func (*Store) ReadDelta ¶
ReadDelta reads a given delta number. The delta can be a number retrieved from the header, or it can be one of the above DeltaLatest, or DeltaPrior constants to read specific recent or nearly recent versions.
func (*Store) ReadHeader ¶
ReadHeader attempts to read the header from the storefile.
func (*Store) Set ¶
Set sets the name of this store. Used to parse the command line.
func (*Store) TempFile ¶
TempFile is used by the naming convention to generate temp files. We just use the number as the extension.
func (*Store) Type ¶
Type returns a short description of the type of the store. Used by the command parsing to print help.
func (*Store) Write ¶
Write writes a new version to the surefile.
type Tags ¶
type Tags struct {
// contains filtered or unexported fields
}
Tags wraps the store as a 'Value' to use the tags as a command line argument.
func NewTags ¶
NewTags create a new Tags struct, wrapping a given store.
func (Tags) Set ¶
Set adds a new tag, from the command line parsing. Must be of the form key=value.