Documentation ¶
Index ¶
- Variables
- type DirNode
- func (n *DirNode) Close() error
- func (n *DirNode) Delete() error
- func (n *DirNode) Dir(name string) (*DirNode, error)
- func (n *DirNode) DirReader() (*i3vdir.DirReader, error)
- func (n *DirNode) File(name string) (*FileNode, error)
- func (n *DirNode) Inode() uint64
- func (n *DirNode) Metadata() (i3vdir.Metadata, error)
- func (n *DirNode) Path() (string, error)
- func (n *DirNode) UpdateMetadata(md i3vdir.Metadata) error
- type FileNode
- type FileSystem
- func (fs *FileSystem) AddI3vFileFromReader(rs io.ReadSeeker, i3vPath modules.I3vPath) error
- func (fs *FileSystem) CachedFileInfo(i3vPath modules.I3vPath) (modules.FileInfo, error)
- func (fs *FileSystem) CachedList(i3vPath modules.I3vPath, recursive bool) ([]modules.FileInfo, []modules.DirectoryInfo, error)
- func (fs *FileSystem) CachedListOnNode(d *DirNode, recursive bool) ([]modules.FileInfo, []modules.DirectoryInfo, error)
- func (fs *FileSystem) DeleteDir(i3vPath modules.I3vPath) error
- func (fs *FileSystem) DeleteFile(i3vPath modules.I3vPath) error
- func (fs *FileSystem) DirI3vPath(n *DirNode) (sp modules.I3vPath)
- func (fs *FileSystem) DirInfo(i3vPath modules.I3vPath) (modules.DirectoryInfo, error)
- func (fs *FileSystem) DirNodeInfo(n *DirNode) (modules.DirectoryInfo, error)
- func (fs *FileSystem) DirPath(i3vPath modules.I3vPath) string
- func (fs *FileSystem) FileExists(i3vPath modules.I3vPath) (bool, error)
- func (fs *FileSystem) FileI3vPath(n *FileNode) (sp modules.I3vPath)
- func (fs *FileSystem) FileInfo(i3vPath modules.I3vPath, offline map[string]bool, goodForRenew map[string]bool, ...) (modules.FileInfo, error)
- func (fs *FileSystem) FileNodeInfo(n *FileNode) (modules.FileInfo, error)
- func (fs *FileSystem) FilePath(i3vPath modules.I3vPath) string
- func (n *FileSystem) Inode() uint64
- func (fs *FileSystem) List(i3vPath modules.I3vPath, recursive bool, ...) ([]modules.FileInfo, []modules.DirectoryInfo, error)
- func (fs *FileSystem) NewI3vDir(i3vPath modules.I3vPath, mode os.FileMode) error
- func (fs *FileSystem) NewI3vFile(i3vPath modules.I3vPath, source string, ec modules.ErasureCoder, ...) error
- func (fs *FileSystem) NewI3vFileFromLegacyData(fd i3vfile.FileData) (*FileNode, error)
- func (fs *FileSystem) OpenI3vDir(i3vPath modules.I3vPath) (*DirNode, error)
- func (fs *FileSystem) OpenI3vFile(i3vPath modules.I3vPath) (*FileNode, error)
- func (fs *FileSystem) ReadDir(i3vPath modules.I3vPath) ([]os.FileInfo, error)
- func (fs *FileSystem) RenameDir(oldI3vPath, newI3vPath modules.I3vPath) error
- func (fs *FileSystem) RenameFile(oldI3vPath, newI3vPath modules.I3vPath) error
- func (fs *FileSystem) Root() string
- func (fs *FileSystem) Stat(i3vPath modules.I3vPath) (os.FileInfo, error)
- func (fs *FileSystem) UpdateDirMetadata(i3vPath modules.I3vPath, metadata i3vdir.Metadata) error
- func (fs *FileSystem) Walk(i3vPath modules.I3vPath, walkFn filepath.WalkFunc) error
- func (fs *FileSystem) WriteFile(i3vPath modules.I3vPath, data []byte, perm os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotExist is returned when a file or folder can't be found on disk. ErrNotExist = errors.New("path does not exist") // ErrExists is returned when a file or folder already exists at a given // location. ErrExists = errors.New("a file or folder already exists at the specified path") // ErrDeleteFileIsDir is returned when the file delete method is used but // the filename corresponds to a directory ErrDeleteFileIsDir = errors.New("cannot delete file, file is a directory") )
Functions ¶
This section is empty.
Types ¶
type DirNode ¶
type DirNode struct {
// contains filtered or unexported fields
}
DirNode is a node which references a I3vDir.
func (*DirNode) Close ¶
Close calls close on the DirNode and also removes the dNode from its parent if it's no longer being used and if it doesn't have any children which are currently in use. This happens iteratively for all parent as long as removing a child resulted in them not having any children left.
type FileNode ¶
FileNode is a node which references a I3vFile.
func (*FileNode) Close ¶
Close calls close on the FileNode and also removes the FileNode from its parent if it's no longer being used and if it doesn't have any children which are currently in use. This happens iteratively for all parent as long as removing a child resulted in them not having any children left.
type FileSystem ¶
type FileSystem struct {
DirNode
}
FileSystem implements a thread-safe filesystem for I3v for loading I3vFiles, I3vDirs and potentially other supported I3v types in the future.
func New ¶
func New(root string, log *persist.Logger, wal *writeaheadlog.WAL) (*FileSystem, error)
New creates a new FileSystem at the specified root path. The folder will be created if it doesn't exist already.
func (*FileSystem) AddI3vFileFromReader ¶
func (fs *FileSystem) AddI3vFileFromReader(rs io.ReadSeeker, i3vPath modules.I3vPath) error
AddI3vFileFromReader adds an existing I3vFile to the set and stores it on disk. If the exact same file already exists, this is a no-op. If a file already exists with a different UID, the UID will be updated and a unique path will be chosen. If no file exists, the UID will be updated but the path remains the same.
func (*FileSystem) CachedFileInfo ¶
CachedFileInfo returns the cached File Information of the i3vfile
func (*FileSystem) CachedList ¶
func (fs *FileSystem) CachedList(i3vPath modules.I3vPath, recursive bool) ([]modules.FileInfo, []modules.DirectoryInfo, error)
CachedList lists the files and directories within a I3vDir.
func (*FileSystem) CachedListOnNode ¶
func (fs *FileSystem) CachedListOnNode(d *DirNode, recursive bool) ([]modules.FileInfo, []modules.DirectoryInfo, error)
CachedListOnNode will return the files and directories within a given i3vdir node.
func (*FileSystem) DeleteDir ¶
func (fs *FileSystem) DeleteDir(i3vPath modules.I3vPath) error
DeleteDir deletes a dir from the filesystem. The dir will be marked as 'deleted' which should cause all remaining instances of the dir to be close shortly. Only when all instances of the dir are closed it will be removed from the tree. This means that as long as the deletion is in progress, no new file of the same path can be created and the existing file can't be opened until all instances of it are closed.
func (*FileSystem) DeleteFile ¶
func (fs *FileSystem) DeleteFile(i3vPath modules.I3vPath) error
DeleteFile deletes a file from the filesystem. The file will be marked as 'deleted' which should cause all remaining instances of the file to be closed shortly. Only when all instances of the file are closed it will be removed from the tree. This means that as long as the deletion is in progress, no new file of the same path can be created and the existing file can't be opened until all instances of it are closed.
func (*FileSystem) DirI3vPath ¶
func (fs *FileSystem) DirI3vPath(n *DirNode) (sp modules.I3vPath)
DirI3vPath returns the I3vPath of a dir node.
func (*FileSystem) DirInfo ¶
func (fs *FileSystem) DirInfo(i3vPath modules.I3vPath) (modules.DirectoryInfo, error)
DirInfo returns the Directory Information of the i3vdir
func (*FileSystem) DirNodeInfo ¶
func (fs *FileSystem) DirNodeInfo(n *DirNode) (modules.DirectoryInfo, error)
DirNodeInfo will return the DirectoryInfo of a i3vdir given the node. This is more efficient than calling fs.DirInfo.
func (*FileSystem) DirPath ¶
func (fs *FileSystem) DirPath(i3vPath modules.I3vPath) string
DirPath converts a I3vPath into a dir's system path.
func (*FileSystem) FileExists ¶
func (fs *FileSystem) FileExists(i3vPath modules.I3vPath) (bool, error)
FileExists checks to see if a file with the provided i3vPath already exists in the renter.
func (*FileSystem) FileI3vPath ¶
func (fs *FileSystem) FileI3vPath(n *FileNode) (sp modules.I3vPath)
FileI3vPath returns the I3vPath of a file node.
func (*FileSystem) FileInfo ¶
func (fs *FileSystem) FileInfo(i3vPath modules.I3vPath, offline map[string]bool, goodForRenew map[string]bool, contracts map[string]modules.RenterContract) (modules.FileInfo, error)
FileInfo returns the File Information of the i3vfile
func (*FileSystem) FileNodeInfo ¶
func (fs *FileSystem) FileNodeInfo(n *FileNode) (modules.FileInfo, error)
FileNodeInfo returns the FileInfo of a i3vfile given the node for the i3vfile. This is faster than calling fs.FileInfo.
func (*FileSystem) FilePath ¶
func (fs *FileSystem) FilePath(i3vPath modules.I3vPath) string
FilePath converts a I3vPath into a file's system path.
func (*FileSystem) Inode ¶
func (n *FileSystem) Inode() uint64
NID returns the node's unique identifier.
func (*FileSystem) List ¶
func (fs *FileSystem) List(i3vPath modules.I3vPath, recursive bool, offlineMap, goodForRenewMap map[string]bool, contractsMap map[string]modules.RenterContract) ([]modules.FileInfo, []modules.DirectoryInfo, error)
List lists the files and directories within a I3vDir.
func (*FileSystem) NewI3vFile ¶
func (fs *FileSystem) NewI3vFile(i3vPath modules.I3vPath, source string, ec modules.ErasureCoder, mk crypto.CipherKey, fileSize uint64, fileMode os.FileMode, disablePartialUpload bool) error
NewI3vFile creates a I3vFile at the specified i3vPath.
func (*FileSystem) NewI3vFileFromLegacyData ¶
func (fs *FileSystem) NewI3vFileFromLegacyData(fd i3vfile.FileData) (*FileNode, error)
NewI3vFileFromLegacyData creates a new I3vFile from data that was previously loaded from a legacy file.
func (*FileSystem) OpenI3vDir ¶
func (fs *FileSystem) OpenI3vDir(i3vPath modules.I3vPath) (*DirNode, error)
OpenI3vDir opens a I3vDir and adds it and all of its parents to the filesystem tree.
func (*FileSystem) OpenI3vFile ¶
func (fs *FileSystem) OpenI3vFile(i3vPath modules.I3vPath) (*FileNode, error)
OpenI3vFile opens a I3vFile and adds it and all of its parents to the filesystem tree.
func (*FileSystem) ReadDir ¶
ReadDir is a wrapper of ioutil.ReadDir which takes a I3vPath as an argument instead of a system path.
func (*FileSystem) RenameDir ¶
func (fs *FileSystem) RenameDir(oldI3vPath, newI3vPath modules.I3vPath) error
RenameDir takes an existing directory and changes the path. The original directory must exist, and there must not be any directory that already has the replacement path. All i3v files within directory will also be renamed
func (*FileSystem) RenameFile ¶
func (fs *FileSystem) RenameFile(oldI3vPath, newI3vPath modules.I3vPath) error
RenameFile renames the file with oldI3vPath to newI3vPath.
func (*FileSystem) Root ¶
func (fs *FileSystem) Root() string
Root returns the root system path of the FileSystem.
func (*FileSystem) Stat ¶
Stat is a wrapper for os.Stat which takes a I3vPath as an argument instead of a system path.
func (*FileSystem) UpdateDirMetadata ¶
UpdateDirMetadata updates the metadata of a I3vDir.