fs

package
v0.0.0-...-52bbd4c Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache currently not used

func NewCache

func NewCache(storage *Storage) (*Cache, error)

NewCache creates a new cache storage

func (*Cache) Get

func (c *Cache) Get(key string) (value string, ok bool)

Get retrieves the given data from the cache

func (*Cache) Put

func (c *Cache) Put(key string, value string) error

Put adds the data to the cache

type DiffNode

type DiffNode struct {
	Hash      []byte
	Diff      []diffmatchpatch.Diff
	Next      string
	NextBoxer tribecrypto.FileBoxer
}

DiffNode : Files are stored on IPFS as a linked list of diffs. DiffNode is a node in this list.

func DecodeDiffNode

func DecodeDiffNode(data []byte) (*DiffNode, error)

DecodeDiffNode decodes a DiffNode

func (*DiffNode) Encode

func (diff *DiffNode) Encode() ([]byte, error)

Encode encodes the diff node

func (*DiffNode) Encrypt

func (diff *DiffNode) Encrypt(boxer tribecrypto.FileBoxer) (io.Reader, error)

Encrypt encrypts the DiffNode with the given secret key

type File

type File struct {
	Meta           *meta.FileMeta
	PendingChanges *meta.FileMeta
	DataPath       string
	MetaPath       string
	OrigPath       string
	// contains filtered or unexported fields
}

File represents a file that is shared in a peer to peer mode

func LoadPTPFile

func LoadPTPFile(filePath string) (*File, error)

LoadPTPFile loads a File from the disk

func NewFileFromMeta

func NewFileFromMeta(dataDir, metaDir string, fileMeta *meta.FileMeta, ipfs ipfsapi.IIpfs, storage *Storage) (*File, error)

NewFileFromMeta creates a new File instance from shared file meta data

func NewGroupFile

func NewGroupFile(filePath string, writeAccessList []ethcommon.Address, groupAddress string, storage *Storage) (*File, error)

NewGroupFile creates a new file in the group's directory

func NewGroupFileFromMeta

func NewGroupFileFromMeta(fileMeta *meta.FileMeta, groupAddress string, groupName string, storage *Storage) (*File, error)

NewGroupFileFromMeta creates a new File from the given group file meta data

func (*File) Download

func (f *File) Download(storage *Storage, ipfs ipfsapi.IIpfs)

Download downloads all the necessary DiffNodes and patches the file along the way

func (*File) GrantWriteAccess

func (f *File) GrantWriteAccess(user, target ethcommon.Address) error

GrantWriteAccess grants write access to a user

func (*File) RevokeWriteAccess

func (f *File) RevokeWriteAccess(user, target ethcommon.Address) error

RevokeWriteAccess revokes write access from a user

func (*File) SaveMetadata

func (f *File) SaveMetadata() error

SaveMetadata saves FileMetaData to disk

func (*File) Update

func (f *File) Update(fileMeta *meta.FileMeta, storage *Storage, ipfs ipfsapi.IIpfs) error

Update updates the file's IPFS hash and if it has changed it downloads its contents

func (*File) UploadDiff

func (f *File) UploadDiff(ipfs ipfsapi.IIpfs) (string, error)

UploadDiff adds the current DiffNode to IPFS

type GroupRepo

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

GroupRepo is responsible for managing and maintaining a group's file repository

func NewGroupRepo

func NewGroupRepo(group interfaces.IGroup, user ethcommon.Address, storage *Storage, ipfs ipfs.IIpfs) (*GroupRepo, error)

NewGroupRepo creates a new GroupRepo

func (*GroupRepo) CommitChanges

func (repo *GroupRepo) CommitChanges(boxer tribecrypto.SymmetricKey) (string, error)

CommitChanges encrypts and adds the repo's changes to IPFS

func (*GroupRepo) Files

func (repo *GroupRepo) Files() []*File

Files returns a list of the repo's files

func (*GroupRepo) Get

func (repo *GroupRepo) Get(fileName string) *File

Get retrieves a file from the repo

func (*GroupRepo) IpfsHash

func (repo *GroupRepo) IpfsHash() string

IpfsHash returns the current IPFS hash of the group repository

func (*GroupRepo) IsValidChangeSet

func (repo *GroupRepo) IsValidChangeSet(newIpfsHash string, boxer tribecrypto.SymmetricKey, address ethcommon.Address) error

IsValidChangeSet verifies if a proposed change set is valid or not

func (*GroupRepo) Update

func (repo *GroupRepo) Update(newIpfsHash string) error

Update updates the group repository according to the new IPFS hash

type IFile

type IFile interface {
	Share()
}

IFile is an interface for the files which can be shared

type Storage

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

Storage is a struct of the directory paths and has functions that are responsible for the file level functionalities

func NewStorage

func NewStorage(basePath string) *Storage

NewStorage creates a new Storage object

func (*Storage) CopyFileIntoGroupFiles

func (storage *Storage) CopyFileIntoGroupFiles(filePath, groupName string) error

CopyFileIntoGroupFiles copies a file to the group's directory

func (*Storage) CopyFileIntoMyFiles

func (storage *Storage) CopyFileIntoMyFiles(filePath string) (string, error)

CopyFileIntoMyFiles copies a file to the user's private directory

func (*Storage) CopyFileIntoPublicDir

func (storage *Storage) CopyFileIntoPublicDir(filePath string) error

CopyFileIntoPublicDir copies a file to the user's public directory

func (*Storage) DownloadAndDecryptWithFileBoxer

func (storage *Storage) DownloadAndDecryptWithFileBoxer(boxer tribecrypto.FileBoxer, ipfsHash string, ipfs ipfsapi.IIpfs) ([]byte, error)

DownloadAndDecryptWithFileBoxer downloads a file from IPFS and decrypts its contents with a FileBoxer

func (*Storage) DownloadAndDecryptWithSymmetricKey

func (storage *Storage) DownloadAndDecryptWithSymmetricKey(boxer tribecrypto.SymmetricKey, ipfsHash string, ipfs ipfsapi.IIpfs) ([]byte, error)

DownloadAndDecryptWithSymmetricKey downloads a file from IPFS and decrypts its contents with a symmetric key

func (*Storage) DownloadTmpFile

func (storage *Storage) DownloadTmpFile(ipfsHash string, ipfs ipfsapi.IIpfs) (string, error)

DownloadTmpFile downloads a file from IPFS to a temporary directory

func (*Storage) GetGroupFileMetas

func (storage *Storage) GetGroupFileMetas(groupAddress string) ([]*meta.FileMeta, error)

GetGroupFileMetas loads all file metas belonging to the group

func (*Storage) GetGroupMetas

func (storage *Storage) GetGroupMetas() ([]*meta.GroupMeta, error)

GetGroupMetas loads all the locally stored group meta data from directory data/userdata/metas/GA/

func (*Storage) GroupFileDataDir

func (storage *Storage) GroupFileDataDir(groupName string) string

GroupFileDataDir returns the directory in which the physical group files are stored

func (*Storage) GroupFileMetaDir

func (storage *Storage) GroupFileMetaDir(id string) string

GroupFileMetaDir returns the directory in which group file metas are stored

func (*Storage) GroupFileOrigDir

func (storage *Storage) GroupFileOrigDir(id string) string

GroupFileOrigDir ...

func (*Storage) GroupMetaDir

func (storage *Storage) GroupMetaDir() string

GroupMetaDir returns the directory in which group metas are stored

func (*Storage) Init

func (storage *Storage) Init(username string)

Init creates the directory structure defined in Storage

func (*Storage) LoadAccountData

func (storage *Storage) LoadAccountData() ([]byte, error)

LoadAccountData loads account data from the disk

func (*Storage) MakeGroupDir

func (storage *Storage) MakeGroupDir(name string, address string)

MakeGroupDir creates the directory structure needed by a group

func (*Storage) SaveAccountData

func (storage *Storage) SaveAccountData(data []byte) error

SaveAccountData saves account data to disk

func (*Storage) SaveGroupMeta

func (storage *Storage) SaveGroupMeta(groupMeta *meta.GroupMeta) error

SaveGroupMeta saves a group meta to disk

func (*Storage) UserFilesPath

func (storage *Storage) UserFilesPath() string

UserFilesPath returns the path to the user's files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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