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 (
//S_IFREG
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 ErrFileTagPresent = errors.New("file status is not available") )
var ( //MetaVersion MetaVersion uint8 = 2 //ErrDeletedFeed ErrDeletedFeed = errors.New("deleted feed") ErrUnknownFeed = errors.New("unknown value in feed") )
var ( //ErrGzipBlSize ErrGzipBlSize = fmt.Errorf("gzip: block size cannot be less than %d", minBlockSizeForGzip) )
var ( //ErrInvalidOffset 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
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
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
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
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
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
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, uint32 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
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
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader
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.
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