Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(dataToCompress []byte, compression string, blockSize uint32) ([]byte, error)
- func Decompress(dataToDecompress []byte, compression string, blockSize uint32) ([]byte, error)
- type BlockInfo
- type Entry
- type File
- func (f *File) AddToFileMap(filePath string, meta *MetaData)
- func (f *File) AddToTagMap(filePath string, tag uint32)
- func (f *File) BackupFromFileName(fileNameWithPath, podPassword string) (*MetaData, error)
- func (f *File) Chmod(podFileWithPath, podPassword string, mode uint32) error
- func (f *File) DeleteFromTagMap(filePath string)
- func (f *File) Download(podFileWithPath, podPassword string) (io.ReadCloser, uint64, error)
- func (f *File) GetFromFileMap(filePath string) *MetaData
- func (f *File) GetInode(podPassword, filePath string) *MetaData
- func (f *File) GetMetaFromFileName(fileNameWithPath, podPassword string, userAddress utils.Address) (*MetaData, error)
- func (f *File) GetStats(podName, podFileWithPath, podPassword string) (*Stats, error)
- func (f *File) IsFileAlreadyPresent(podPassword, fileWithPath string) bool
- func (f *File) ListFiles(files []string, podPassword string) ([]Entry, error)
- func (f *File) LoadFileMeta(fileNameWithPath, podPassword string) error
- func (f *File) LoadFromTagMap(filePath string) uint32
- func (f *File) OpenFileForIndex(podFile, podPassword string) (*Reader, error)
- func (f *File) PutMetaForFile(meta *MetaData, podPassword string) error
- func (f *File) ReadSeeker(podFileWithPath, podPassword string) (io.ReadSeekCloser, uint64, error)
- func (f *File) RemoveAllFromFileMap()
- func (f *File) RemoveFromFileMap(filePath string)
- func (f *File) RenameFromFileName(fileNameWithPath, newFileNameWithPath, podPassword string) (*MetaData, error)
- func (f *File) RmFile(podFileWithPath, podPassword string) error
- func (f *File) Status(podFileWithPath, podPassword string) (int64, int64, int64, error)
- func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSize, mode uint32, ...) error
- func (f *File) WriteAt(podFileWithPath, podPassword string, update io.Reader, offset uint64, ...) (int, error)
- type IFile
- type INode
- type MetaData
- type Reader
- type Stats
Constants ¶
const ( MinBlockSize uint32 = 1000000 MaxBlockSize uint32 = 8000000 // S_IFREG is the regular file type S_IFREG = 0100000 )
Variables ¶
var ( // ErrFileAlreadyPresent denotes file is present ErrFileAlreadyPresent = errors.New("file already present in the destination dir") // ErrFileNotFound denotes file is not found in dfs ErrFileNotFound = errors.New("file not found in dfs") // ErrFileTagPresent denotes file status is not available ErrFileTagPresent = errors.New("file status is not available") )
var ( // MetaVersion is the version of the meta data MetaVersion uint8 = 2 // ErrDeletedFeed is returned when the feed is deleted ErrDeletedFeed = errors.New("deleted feed") // ErrUnknownFeed is returned when the feed is unknown ErrUnknownFeed = errors.New("unknown value in feed") )
var (
ErrInvalidBlockSize = fmt.Errorf("upload: block size must be between %d - %d (1Mb - 8Mb)", MinBlockSize, MaxBlockSize)
)
var ( // ErrInvalidOffset is returned when the offset is invalid ErrInvalidOffset = errors.New("invalid offset") )
Functions ¶
Types ¶
type BlockInfo ¶ added in v0.5.3
type BlockInfo struct { Size uint32 `json:"size"` CompressedSize uint32 `json:"compressedSize"` Reference utils.Reference `json:"reference"` }
BlockInfo is the structure of the block info
type Entry ¶ added in v0.5.3
type Entry struct { Name string `json:"name"` ContentType string `json:"contentType"` Size string `json:"size,omitempty"` BlockSize string `json:"blockSize,omitempty"` CreationTime string `json:"creationTime"` ModificationTime string `json:"modificationTime"` AccessTime string `json:"accessTime"` Mode uint32 `json:"mode"` }
Entry is the structure of the entry
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a file in a pod
func NewFile ¶
func NewFile(podName string, client blockstore.Client, fd *feed.API, user utils.Address, m taskmanager.TaskManagerGO, logger logging.Logger) *File
NewFile creates the base file object which has all the methods related to file manipulation.
func (*File) AddToFileMap ¶
AddToFileMap adds a file metadata into fileMap
func (*File) AddToTagMap ¶ added in v0.9.2
AddToTagMap adds a mapping filename and tag into tagMap
func (*File) BackupFromFileName ¶ added in v0.7.0
BackupFromFileName is used to backup a file
func (*File) Chmod ¶ added in v0.9.2
Chmod does all the validation for the existence of the file and changes file mode
func (*File) DeleteFromTagMap ¶ added in v0.9.2
DeleteFromTagMap deletes a tag from tagMap
func (*File) Download ¶
Download does all the validation for the existence of the file and creates a Reader to read the contents of the file from the pod.
func (*File) GetFromFileMap ¶
GetFromFileMap gets file metadata from the fileMap
func (*File) GetMetaFromFileName ¶ added in v0.5.3
func (f *File) GetMetaFromFileName(fileNameWithPath, podPassword string, userAddress utils.Address) (*MetaData, error)
GetMetaFromFileName is used to get meta from file name
func (*File) GetStats ¶ added in v0.5.3
GetStats given a filename this function returns all the information about the file including the block information.
func (*File) IsFileAlreadyPresent ¶ added in v0.5.3
IsFileAlreadyPresent checks if a file is present in the fileMap
func (*File) ListFiles ¶
ListFiles given a list of files, list files gives back the information related to each file.
func (*File) LoadFileMeta ¶
LoadFileMeta is used in syncing
func (*File) LoadFromTagMap ¶ added in v0.9.2
LoadFromTagMap gets a tag from tagMap
func (*File) OpenFileForIndex ¶
OpenFileForIndex opens file for indexing for document db from pod filepath TODO test skipcq: TCV-001
func (*File) PutMetaForFile ¶ added in v0.6.2
PutMetaForFile is used to put meta for a file
func (*File) ReadSeeker ¶ added in v0.9.1
ReadSeeker does all the validation for the existence of the file and creates a ReadSeekCloser to read the contents of the file from the pod.
func (*File) RemoveAllFromFileMap ¶ added in v0.5.3
func (f *File) RemoveAllFromFileMap()
RemoveAllFromFileMap resets the fileMap
func (*File) RemoveFromFileMap ¶
RemoveFromFileMap removes a file metadata from fileMap
func (*File) RenameFromFileName ¶ added in v0.9.1
func (f *File) RenameFromFileName(fileNameWithPath, newFileNameWithPath, podPassword string) (*MetaData, error)
RenameFromFileName is used to rename a file
func (*File) RmFile ¶ added in v0.5.3
RmFile deletes all the blocks of a file, and it related metadata from the Swarm network.
func (*File) Status ¶ added in v0.9.2
Status does all the validation for the existence of the file and checks file sync status
func (*File) Upload ¶
func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSize, mode uint32, podPath, compression, podPassword string) error
Upload uploads a given blob of bytes as a file in the pod. It also splits the file into number of blocks. the size of the block is provided during upload. This function also does compression of the blocks gzip/snappy if it is requested during the upload.
type IFile ¶ added in v0.5.3
type IFile interface { Upload(fd io.Reader, podFileName string, fileSize int64, blockSize, mode uint32, podPath, compression, podPassword string) error Download(podFileWithPath, podPassword string) (io.ReadCloser, uint64, error) ListFiles(files []string, podPassword string) ([]Entry, error) GetStats(podName, podFileWithPath, podPassword string) (*Stats, error) RmFile(podFileWithPath, podPassword string) error LoadFileMeta(fileNameWithPath, podPassword string) error }
IFile is the interface for file operations
type INode ¶ added in v0.5.3
type INode struct {
Blocks []*BlockInfo `json:"blocks"`
}
INode is the structure of the inode
type MetaData ¶ added in v0.5.3
type MetaData struct { Version uint8 `json:"version"` Path string `json:"filePath"` Name string `json:"fileName"` Size uint64 `json:"fileSize"` BlockSize uint32 `json:"blockSize"` ContentType string `json:"contentType"` Compression string `json:"compression"` CreationTime int64 `json:"creationTime"` AccessTime int64 `json:"accessTime"` ModificationTime int64 `json:"modificationTime"` InodeAddress []byte `json:"fileInodeReference"` Mode uint32 `json:"mode"` }
MetaData is the structure of the file metadata
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a struct to read a file from the pod
func NewReader ¶
func NewReader(fileInode INode, client blockstore.Client, fileSize uint64, blockSize uint32, compression string, cache bool) *Reader
NewReader create a new reader object to read a file from the pod based on its configuration.
func (*Reader) Read ¶
Read reads a given segment of the file from the pod and returns it. it does all the related function like block extraction, block un-compression etc.
type Stats ¶ added in v0.5.3
type Stats struct { PodName string `json:"podName"` Mode uint32 `json:"mode"` FilePath string `json:"filePath"` FileName string `json:"fileName"` FileSize string `json:"fileSize"` BlockSize string `json:"blockSize"` Compression string `json:"compression"` ContentType string `json:"contentType"` CreationTime string `json:"creationTime"` ModificationTime string `json:"modificationTime"` AccessTime string `json:"accessTime"` }
Stats is the structure of the file stats