Documentation ¶
Overview ¶
Package storage provides the file info storage system.
Index ¶
- type Directory
- func (d Directory) AddSea(p, name, hash string, sea *FragmentSea) error
- func (d *Directory) CreateDirectory(p string) (*Directory, error)
- func (d *Directory) CreateFile(p, name, hash, keyHash string, size int64, fragments []*Fragment) error
- func (d *Directory) DeleteDirectory(p, name string, userOrGroup, shared bool) (seaOperations map[string][]*sea.Operation, keyUsed map[string]int, err error)
- func (d *Directory) DeleteDirectoryKey() map[string]int
- func (d *Directory) DeleteFile(p, name string, userOrGroup, shared bool) (map[string][]*sea.Operation, string, error)
- func (d *Directory) GenerateSeaOperations(action uint, shared bool) map[string][]*sea.Operation
- func (d *Directory) GetHash() string
- func (d *Directory) GetKeys() []string
- func (d *Directory) GetName() string
- func (d *Directory) GetSize() int64
- func (d *Directory) List(p string) ([]INodeInfo, error)
- func (d *Directory) Move(p, name, newPath string) error
- func (d *Directory) ToBytes() []byte
- func (d *Directory) ToJson() string
- func (d *Directory) UpdateFileData(p, name, hash string, size int64, fragments []*Fragment, ...) (map[string][]*sea.Operation, error)
- func (d *Directory) UpdateFileKey(p, name, keyIndex, hash string, size int64, fragments []*Fragment, ...) (map[string]int, map[string][]*sea.Operation, error)
- func (d *Directory) UpdateName(p, name, newName string) error
- type File
- type FileInfo
- type FileKey
- type FileKeyMap
- type Fragment
- type FragmentSea
- type INode
- type INodeInfo
- type Root
- func (root *Root) AddSea(p, name, hash string, sea *FragmentSea) error
- func (root *Root) CreateDirectory(p string) error
- func (root *Root) CreateFile(p string, info FileInfo) error
- func (root *Root) DeleteDirectory(p, name string, userOrGroup bool) (map[string][]*sea.Operation, error)
- func (root *Root) DeleteFile(p, name string, userOrGroup bool) (map[string][]*sea.Operation, error)
- func (root *Root) GetDirectory(p string) (dir *Directory, err error)
- func (root *Root) GetFile(p, name string) (file FileInfo, err error)
- func (root *Root) GetINode(p, name string) (INode, error)
- func (root *Root) GetSharedDirectory(p string) (dir *Directory, err error)
- func (root *Root) GetSharedFile(p, name string) (file FileInfo, err error)
- func (root *Root) GetSharedINode(p, name string) (INode, error)
- func (root *Root) ListDirectory(p string) (iNodes []INodeInfo, err error)
- func (root *Root) ListSharedDirectory(p string) (iNodes []INodeInfo, err error)
- func (root *Root) Move(p, name, newPath string) error
- func (root *Root) PublishKey(publicKey, keyIndex, key string) error
- func (root *Root) ShareFiles(p, name, dst string, userOrGroup bool) (map[string][]*sea.Operation, []string, error)
- func (root *Root) ToBytes() []byte
- func (root *Root) UpdateFileData(p string, info FileInfo, userOrGroup bool) (map[string][]*sea.Operation, error)
- func (root *Root) UpdateFileKey(p string, info FileInfo, userOrGroup bool) (map[string][]*sea.Operation, error)
- func (root *Root) UpdateName(p, name, newName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directory ¶
type Directory struct { Name string Size int64 Hash string INodes []INode // contains filtered or unexported fields }
func DirectoryFromBytes ¶
func NewDirectory ¶
func (Directory) AddSea ¶
func (d Directory) AddSea(p, name, hash string, sea *FragmentSea) error
Add Fragment stored sea
func (*Directory) CreateDirectory ¶
Target directories recursively If there is the same Name file exists, it will return error. Else, it will return the pointer of the determination directory INode.
func (*Directory) CreateFile ¶
func (d *Directory) CreateFile(p, name, hash, keyHash string, size int64, fragments []*Fragment) error
Store the file into the path.
func (*Directory) DeleteDirectory ¶
func (d *Directory) DeleteDirectory(p, name string, userOrGroup, shared bool) (seaOperations map[string][]*sea.Operation, keyUsed map[string]int, err error)
Delete iNode of the directory finding by the path.
func (*Directory) DeleteDirectoryKey ¶
Delete directory Key.
func (*Directory) DeleteFile ¶
func (d *Directory) DeleteFile(p, name string, userOrGroup, shared bool) (map[string][]*sea.Operation, string, error)
Delete the file finding by the Name under the path.
func (*Directory) GenerateSeaOperations ¶
func (*Directory) UpdateFileData ¶
func (d *Directory) UpdateFileData(p, name, hash string, size int64, fragments []*Fragment, userOrGroup, shared bool) (map[string][]*sea.Operation, error)
Update the data of file finding by the filename and the path of file.
func (*Directory) UpdateFileKey ¶
func (d *Directory) UpdateFileKey(p, name, keyIndex, hash string, size int64, fragments []*Fragment, userOrGroup, shared bool) (map[string]int, map[string][]*sea.Operation, error)
Update the Key of file
func (*Directory) UpdateName ¶
Update the Name of directory finding by the path.
type File ¶
type File struct { Name string Size int64 Hash string KeyIndex string Fragments []*Fragment // contains filtered or unexported fields }
func FileFromBytes ¶
func (*File) GenerateSeaOperations ¶
type FileKeyMap ¶
type FileKeyMap struct {
Keys []*FileKey
}
FileKeyMap provides file keys manage.
func NewFileKeyMap ¶
func NewFileKeyMap() *FileKeyMap
NewFileKeyMap is the construct for FileKeyMap.
func (*FileKeyMap) AddKey ¶
func (fkm *FileKeyMap) AddKey(key string, used bool) string
AddKey add new information of key. If used, the used count of key will be 1. Else, it will be 0.
func (*FileKeyMap) GetKey ¶
func (fkm *FileKeyMap) GetKey(index string) *FileKey
GetKey search the FileKey by index. If it exists, it will be return. Else, returns nil.
func (*FileKeyMap) PublishKey ¶
func (fkm *FileKeyMap) PublishKey(publicKey, keyIndex, key string) error
PublishKey check key whether valid and publish it.
func (*FileKeyMap) UpdateKeyUsed ¶
func (fkm *FileKeyMap) UpdateKeyUsed(keyUsed map[string]int)
UpdateKeyUsed update used count of keys by index and count.
type Fragment ¶
type Fragment struct { Hash string Size int64 Seas []*FragmentSea }
func NewFragment ¶
func NewFragment(hash string, seas []*FragmentSea) *Fragment
type FragmentSea ¶
func NewFragmentSea ¶
func NewFragmentSea(address, publicKey string, timestamp time.Time) *FragmentSea
type Root ¶
type Root struct { Home *Directory Keys *FileKeyMap }
Root store information of files and Keys used to encryption. Store the information of private files in 'Home' directory. Store the information of shared files in 'Shared' directory.
func NewRoot ¶
func NewRoot(home, share *Directory, keyMap *FileKeyMap) *Root
NewRoot is the construct for Root.
func RootFromBytes ¶
RootFromBytes convert root from byte slice.
func (*Root) AddSea ¶
func (root *Root) AddSea(p, name, hash string, sea *FragmentSea) error
AddSea add fragment stored sea's information to its file.
func (*Root) CreateDirectory ¶
CreateDirectory create directory in the path.
func (*Root) CreateFile ¶
CreateFile generate file in the path and store its information.
func (*Root) DeleteDirectory ¶
func (root *Root) DeleteDirectory(p, name string, userOrGroup bool) (map[string][]*sea.Operation, error)
DeleteDirectory delete directory and files in it.
func (*Root) DeleteFile ¶
DeleteFile delete file in the path.
func (*Root) GetDirectory ¶
GetDirectory returns the information of directory.
func (*Root) GetSharedDirectory ¶
GetSharedDirectory returns the information of directory in the 'shared' directory.
func (*Root) GetSharedFile ¶
GetSharedFile returns the information of file in the 'shared' directory.
func (*Root) GetSharedINode ¶
GetSharedINode returns the information of iNode in the 'shared' directory.
func (*Root) ListDirectory ¶
ListDirectory list the information of iNodes in the directory.
func (*Root) ListSharedDirectory ¶
ListSharedDirectory list the information of iNodes in the 'shared' directory.
func (*Root) PublishKey ¶
PublishKey publish the key encrypted by public key.
func (*Root) ShareFiles ¶
func (root *Root) ShareFiles(p, name, dst string, userOrGroup bool) (map[string][]*sea.Operation, []string, error)
ShareFiles copy the information of file to 'shared' directory.
func (*Root) UpdateFileData ¶
func (root *Root) UpdateFileData(p string, info FileInfo, userOrGroup bool) (map[string][]*sea.Operation, error)
UpdateFileData change the information of file.
func (*Root) UpdateFileKey ¶
func (root *Root) UpdateFileKey(p string, info FileInfo, userOrGroup bool) (map[string][]*sea.Operation, error)
UpdateFileKey change the encryption key of file and its information.
func (*Root) UpdateName ¶
UpdateName change the target iNode's name to new name.