Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyUpdates(updates ...writeaheadlog.Update) error
- func IsSiaDirUpdate(update writeaheadlog.Update) bool
- type Metadata
- type SiaDir
- type SiaDirSet
- func (sds *SiaDirSet) Delete(siaPath modules.SiaPath) error
- func (sds *SiaDirSet) Exists(siaPath modules.SiaPath) (bool, error)
- func (sds *SiaDirSet) InitRootDir() error
- func (sds *SiaDirSet) NewSiaDir(siaPath modules.SiaPath) (*SiaDirSetEntry, error)
- func (sds *SiaDirSet) Open(siaPath modules.SiaPath) (*SiaDirSetEntry, error)
- func (sds *SiaDirSet) UpdateMetadata(siaPath modules.SiaPath, metadata Metadata) error
- type SiaDirSetEntry
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) )
Variables ¶
var ( // ErrPathOverload is an error when a siadir already exists at that location ErrPathOverload = errors.New("a siadir already exists at that location") // ErrUnknownPath is an error when a siadir cannot be found with the given path ErrUnknownPath = errors.New("no siadir known with that path") // ErrUnknownThread is an error when a siadir is trying to be closed by a // thread that is not in the threadMap ErrUnknownThread = errors.New("thread should not be calling Close(), does not have control of the siadir") )
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 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 Metadata ¶
type Metadata struct { // AggregateNumFiles is the total number of files in a directory and any // sub directory AggregateNumFiles uint64 `json:"aggregatenumfiles"` // AggregateSize is the total amount of data in the files and sub // directories AggregateSize uint64 `json:"aggregatesize"` // Health is the health of the most in need file in the directory or any // of the sub directories that are not stuck Health float64 `json:"health"` // LastHealthCheckTime is the oldest LastHealthCheckTime of any of the // siafiles in the siadir or any of the sub directories LastHealthCheckTime time.Time `json:"lasthealthchecktime"` // MinRedundancy is the minimum redundancy of any of the files or sub // directories MinRedundancy float64 `json:"minredundancy"` // ModTime is the last time any of the files or sub directories // was updated ModTime time.Time `json:"modtime"` // NumFiles is the number of files in a directory NumFiles uint64 `json:"numfiles"` // NumStuckChunks is the sum of all the Stuck Chunks of any of the // siafiles in the siadir or any of the sub directories NumStuckChunks uint64 `json:"numstuckchunks"` // NumSubDirs is the number of subdirectories in a directory NumSubDirs uint64 `json:"numsubdirs"` // RootDir is the path to the root directory on disk RootDir string `json:"rootdir"` // SiaPath is the path to the siadir on the sia network SiaPath modules.SiaPath `json:"siapath"` // StuckHealth is the health of the most in need file in the directory // or any of the sub directories, stuck or not stuck StuckHealth float64 `json:"stuckhealth"` }
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(rootDir string, siaPath modules.SiaPath, deps modules.Dependencies, wal *writeaheadlog.WAL) (*SiaDir, 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) UpdateMetadata ¶
UpdateMetadata updates the SiaDir metadata on disk
type SiaDirSet ¶
type SiaDirSet struct {
// contains filtered or unexported fields
}
SiaDirSet handles the thread management for the SiaDirs on disk and in memory
func NewSiaDirSet ¶
func NewSiaDirSet(rootDir string, wal *writeaheadlog.WAL) *SiaDirSet
NewSiaDirSet initializes and returns a SiaDirSet
func (*SiaDirSet) Exists ¶
Exists checks to see if a file with the provided siaPath already exists in the renter
func (*SiaDirSet) InitRootDir ¶
InitRootDir initializes the root directory SiaDir on disk. The root directory is not added in memory or returned.
func (*SiaDirSet) NewSiaDir ¶
func (sds *SiaDirSet) NewSiaDir(siaPath modules.SiaPath) (*SiaDirSetEntry, error)
NewSiaDir creates a new SiaDir and returns a SiaDirSetEntry
type SiaDirSetEntry ¶
type SiaDirSetEntry struct {
// contains filtered or unexported fields
}
SiaDirSetEntry is the exported struct that is returned to the thread accessing the SiaDir and the Entry
func (*SiaDirSetEntry) Close ¶
func (entry *SiaDirSetEntry) Close() error
Close will close the set entry, removing the entry from memory if there are no other entries using the siadir.
Note that 'Close' grabs a lock on the SiaDirSet, do not call this function while holding a lock on the SiaDirSet - standard concurrency conventions though dictate that you should not be calling exported / capitalized functions while holding a lock anyway, but this function is particularly sensitive to that.