filesystem

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRepairNeeded = errors.New("no repair needed")

ErrNoRepairNeeded is the error that no repair is needed

Functions

This section is empty.

Types

type AlwaysSuccessContractManager

type AlwaysSuccessContractManager struct{}

AlwaysSuccessContractManager is the contractManager that always return good condition for all host keys

func (*AlwaysSuccessContractManager) HostHealthMap

HostHealthMap is not used by test case

func (*AlwaysSuccessContractManager) HostHealthMapByID

func (c *AlwaysSuccessContractManager) HostHealthMapByID(ids []enode.ID) storage.HostHealthInfoTable

HostHealthMapByID always return good condition

type FileSystem

type FileSystem interface {
	// File System is could be used as a service with New, Start, and Close
	Start() error
	Close() error

	// Properties
	RootDir() storage.SysPath
	PersistDir() storage.SysPath

	// DxFile related methods, including New, Open, Rename and Delete
	NewDxFile(dxPath storage.DxPath, sourcePath storage.SysPath, force bool, erasureCode erasurecode.ErasureCoder, cipherKey crypto.CipherKey, fileSize uint64, fileMode os.FileMode) (*dxfile.FileSetEntryWithID, error)
	OpenDxFile(path storage.DxPath) (*dxfile.FileSetEntryWithID, error)
	RenameDxFile(prevDxPath, curDxPath storage.DxPath) error
	DeleteDxFile(dxPath storage.DxPath) error

	// DxDir related methods, including New and open
	NewDxDir(path storage.DxPath) (*dxdir.DirSetEntryWithID, error)
	OpenDxDir(path storage.DxPath) (*dxdir.DirSetEntryWithID, error)

	// Upload/Download logic related functions
	InitAndUpdateDirMetadata(path storage.DxPath) error
	SelectDxFileToFix() (*dxfile.FileSetEntryWithID, error)
	RandomStuckDirectory() (*dxdir.DirSetEntryWithID, error)
	OldestLastTimeHealthCheck() (storage.DxPath, time.Time, error)
	RepairNeededChan() chan struct{}
	StuckFoundChan() chan struct{}
	// contains filtered or unexported methods
}

FileSystem is the interface for fileSystem

func New

func New(persistDir string, contractor contractManager) FileSystem

New is the public function used for creating a production fileSystem

type PublicFileSystemAPI

type PublicFileSystemAPI struct {
	// contains filtered or unexported fields
}

PublicFileSystemAPI is the api for file system

func NewPublicFileSystemAPI

func NewPublicFileSystemAPI(fs FileSystem) *PublicFileSystemAPI

NewPublicFileSystemAPI creates a new file system api

func (*PublicFileSystemAPI) Delete

func (api *PublicFileSystemAPI) Delete(path string) string

Delete delete a file specified by the path

func (*PublicFileSystemAPI) DetailedFileInfo

func (api *PublicFileSystemAPI) DetailedFileInfo(path string) storage.FileInfo

DetailedFileInfo returns the detailed file info of a file specified by the path

func (*PublicFileSystemAPI) FileList

func (api *PublicFileSystemAPI) FileList() []storage.FileBriefInfo

FileList is the API function that returns all uploaded files

func (*PublicFileSystemAPI) PersistDir

func (api *PublicFileSystemAPI) PersistDir() string

PersistDir return the directory where the files locates

func (*PublicFileSystemAPI) Rename

func (api *PublicFileSystemAPI) Rename(prevPath, newPath string) string

Rename is the API function that rename a file from prevPath to newPath

func (*PublicFileSystemAPI) RootDir

func (api *PublicFileSystemAPI) RootDir() string

RootDir returns the root directory of the file system

func (*PublicFileSystemAPI) Uploads

func (api *PublicFileSystemAPI) Uploads() []storage.FileBriefInfo

Uploads is the API function that return all files currently uploading in progress

type PublicFileSystemDebugAPI

type PublicFileSystemDebugAPI struct {
	// contains filtered or unexported fields
}

PublicFileSystemDebugAPI is the APIs for the file system

func NewPublicFileSystemDebugAPI

func NewPublicFileSystemDebugAPI(fs *fileSystem) *PublicFileSystemDebugAPI

NewPublicFileSystemDebugAPI is the function to create the PublicFileSystem API with the input file system

func (*PublicFileSystemDebugAPI) CreateRandomFiles

func (api *PublicFileSystemDebugAPI) CreateRandomFiles(numFiles int) string

CreateRandomFiles create some random files. This API is only used in tests The random file is defined randomly by goDeepRate, goWideRate, maxDepth, and missRate

	goDeepRate is the possibility of when creating a file, it goes deep into
 	a subdirectory of the current directory.
	goWideRate is the possibility of when going deep, instead of using an existing
 	directory, it creates a new one
 maxDepth is the maximum directory depth that a file could reach
 missRate is a number between 0 and 1 that defines the possibility that file's sector
    	is missing

Now the params are default to some preset values. These values could be easily changed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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