Documentation ¶
Index ¶
- Constants
- func ApplyUpdates(updates ...writeaheadlog.Update) error
- func CreateAndApplyTransaction(wal *writeaheadlog.WAL, updates ...writeaheadlog.Update) error
- func IsI3vDirUpdate(update writeaheadlog.Update) bool
- type DirReader
- type I3vDir
- func (sd *I3vDir) Delete() error
- func (sd *I3vDir) Deleted() bool
- func (sd *I3vDir) DirReader() (*DirReader, error)
- func (sd *I3vDir) MDPath() string
- func (sd *I3vDir) Metadata() Metadata
- func (sd *I3vDir) Path() string
- func (sd *I3vDir) Rename(targetPath string) error
- func (sd *I3vDir) SetPath(targetPath string)
- func (sd *I3vDir) UpdateMetadata(metadata Metadata) error
- type Metadata
Constants ¶
const ( // I3vDirExtension is the name of the metadata file for the i3v directory I3vDirExtension = ".i3vdir" // DefaultDirHealth is the default health for the directory and the fall // back value when there is an error. This is to protect against falsely // trying to repair directories that had a read error DefaultDirHealth = float64(0) // DefaultDirRedundancy is the default redundancy for the directory and the // fall back value when there is an error. This is to protect against // falsely trying to repair directories that had a read error DefaultDirRedundancy = float64(-1) )
Variables ¶
This section is empty.
Functions ¶
func ApplyUpdates ¶
func ApplyUpdates(updates ...writeaheadlog.Update) error
ApplyUpdates applies a number of writeaheadlog updates to the corresponding I3vDir. This method can apply updates from different I3vDirs and should only be run before the I3vDirs are loaded from disk right after the startup of i3vd. Otherwise we might run into concurrency issues.
func CreateAndApplyTransaction ¶
func CreateAndApplyTransaction(wal *writeaheadlog.WAL, updates ...writeaheadlog.Update) error
CreateAndApplyTransaction is a helper method that creates a writeaheadlog transaction and applies it.
func IsI3vDirUpdate ¶
func IsI3vDirUpdate(update writeaheadlog.Update) bool
IsI3vDirUpdate is a helper method that makes sure that a wal update belongs to the I3vDir package.
Types ¶
type DirReader ¶
type DirReader struct {
// contains filtered or unexported fields
}
DirReader is a helper type that allows reading a raw .i3vdir from disk while keeping the file in memory locked.
type I3vDir ¶
type I3vDir struct {
// contains filtered or unexported fields
}
I3vDir contains the metadata information about a renter directory
func LoadI3vDir ¶
func LoadI3vDir(path string, deps modules.Dependencies, wal *writeaheadlog.WAL) (sd *I3vDir, err error)
LoadI3vDir loads the directory metadata from disk
func New ¶
New creates a new directory in the renter directory and makes sure there is a metadata file in the directory and creates one as needed. This method will also make sure that all the parent directories are created and have metadata files as well and will return the I3vDir containing the information for the directory that matches the i3vPath provided
func (*I3vDir) Delete ¶
Delete removes the directory from disk and marks it as deleted. Once the directory is deleted, attempting to access the directory will return an error.
func (*I3vDir) DirReader ¶
DirReader creates a io.ReadCloser that can be used to read the raw I3vDir from disk.
func (*I3vDir) UpdateMetadata ¶
UpdateMetadata updates the I3vDir metadata on disk
type Metadata ¶
type Metadata struct { // The following fields are aggregate values of the i3vdir. These values are // the totals of the i3vdir and any sub i3vdirs, or are calculated based on // all the values in the subtree AggregateHealth float64 `json:"aggregatehealth"` AggregateLastHealthCheckTime time.Time `json:"aggregatelasthealthchecktime"` AggregateMinRedundancy float64 `json:"aggregateminredundancy"` AggregateModTime time.Time `json:"aggregatemodtime"` AggregateNumFiles uint64 `json:"aggregatenumfiles"` AggregateNumStuckChunks uint64 `json:"aggregatenumstuckchunks"` AggregateNumSubDirs uint64 `json:"aggregatenumsubdirs"` AggregateSize uint64 `json:"aggregatesize"` AggregateStuckHealth float64 `json:"aggregatestuckhealth"` // The following fields are information specific to the i3vdir that is not // an aggregate of the entire sub directory tree Health float64 `json:"health"` LastHealthCheckTime time.Time `json:"lasthealthchecktime"` MinRedundancy float64 `json:"minredundancy"` Mode os.FileMode `json:"mode"` ModTime time.Time `json:"modtime"` NumFiles uint64 `json:"numfiles"` NumStuckChunks uint64 `json:"numstuckchunks"` NumSubDirs uint64 `json:"numsubdirs"` Size uint64 `json:"size"` StuckHealth float64 `json:"stuckhealth"` // Version is the used version of the header file. Version string `json:"version"` }
Metadata is the metadata that is saved to disk as a .i3vdir file