Documentation ¶
Index ¶
- Constants
- func ApplyUpdates(updates ...writeaheadlog.Update) error
- func CreateAndApplyTransaction(wal *writeaheadlog.WAL, updates ...writeaheadlog.Update) error
- func IsSiaDirUpdate(update writeaheadlog.Update) bool
- type DirReader
- type Metadata
- type SiaDir
- func (sd *SiaDir) Delete() error
- func (sd *SiaDir) Deleted() bool
- func (sd *SiaDir) DirReader() (*DirReader, error)
- func (sd *SiaDir) MDPath() string
- func (sd *SiaDir) Metadata() Metadata
- func (sd *SiaDir) Path() string
- func (sd *SiaDir) Rename(targetPath string) error
- func (sd *SiaDir) SetPath(targetPath string)
- func (sd *SiaDir) UpdateMetadata(metadata Metadata) error
Constants ¶
const ( // SiaDirExtension is the name of the metadata file for the sia directory SiaDirExtension = ".siadir" // 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 SiaDir. This method can apply updates from different SiaDirs and should only be run before the SiaDirs are loaded from disk right after the startup of siad. Otherwise we might run into concurrency issues.
func CreateAndApplyTransaction ¶ added in v1.4.2
func CreateAndApplyTransaction(wal *writeaheadlog.WAL, updates ...writeaheadlog.Update) error
CreateAndApplyTransaction is a helper method that creates a writeaheadlog transaction and applies it.
func IsSiaDirUpdate ¶
func IsSiaDirUpdate(update writeaheadlog.Update) bool
IsSiaDirUpdate is a helper method that makes sure that a wal update belongs to the SiaDir package.
Types ¶
type DirReader ¶ added in v1.4.1
type DirReader struct {
// contains filtered or unexported fields
}
DirReader is a helper type that allows reading a raw .siadir from disk while keeping the file in memory locked.
type Metadata ¶
type Metadata struct { // The following fields are aggregate values of the siadir. These values are // the totals of the siadir and any sub siadirs, 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 siadir 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 .siadir file
type SiaDir ¶
type SiaDir struct {
// contains filtered or unexported fields
}
SiaDir contains the metadata information about a renter directory
func LoadSiaDir ¶
func LoadSiaDir(path string, deps modules.Dependencies, wal *writeaheadlog.WAL) (sd *SiaDir, err error)
LoadSiaDir 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 SiaDir containing the information for the directory that matches the siaPath provided
func (*SiaDir) 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 (*SiaDir) DirReader ¶ added in v1.4.1
DirReader creates a io.ReadCloser that can be used to read the raw SiaDir from disk.
func (*SiaDir) UpdateMetadata ¶
UpdateMetadata updates the SiaDir metadata on disk