file

package
v0.0.0-...-b84eec1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	StatusDownload = "download"
	StatusUpload   = "upload"
	StatusSuccess  = "success"
	StatusPending  = "pending"
	StatusFail     = "fail"
)
View Source
const (
	FileMetaDBName = "filemetadb"
)
View Source
const (
	PendingDBName = "pending"
)

Variables

View Source
var (
	ErrEmptySpURL          = errors.New("empty spUrl")
	ErrDownloadTimeout     = errors.New("download timeout")
	ErrPGPDecryptionFailed = errors.New("pgp decryption failed")
	ErrUploadTimeout       = errors.New("upload timeout")
)
View Source
var ErrFileMetaNotFound = errors.New("file meta not found")
View Source
var ErrNoBytesWritten = errors.New("No bytes written to file")
View Source
var ErrNoFileDefined = errors.New("No file defined")

Functions

This section is empty.

Types

type EncryptedArchive

type EncryptedArchive struct {
	FileHash     string
	AbsolutePath string // Absolute position on disk
	Size         int64  // file length in bytes
}

type File

type File struct {
	FilePath    string
	FileKind    int
	Uploaded    bool
	ContentName string
	Type        string
}

type FileMeta

type FileMeta struct {
	FileHash     string
	FileName     string
	FileKind     int
	ContentName  string
	Uploaded     bool
	Hidden       bool
	Expiry       int64
	SpUrl        string
	GraceSeconds int
	Expired      bool
	HasThumbnail bool
}

type Handler

type Handler struct {
	FileMetaHandler *handler
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(cfg *config.Configuration, wallet *account.Wallet, storageDir, userAccountDir string, accountGetter func() *account.Account) (*Handler, error)

func (*Handler) Close

func (me *Handler) Close() error

func (*Handler) DecryptDirectory

func (me *Handler) DecryptDirectory(dst string, src string, pw, pgpPrivateKey []byte) error

func (*Handler) EncryptDirectory

func (me *Handler) EncryptDirectory(dst string, src string, pgpPublicKeys [][]byte) error

func (*Handler) FileMatchesQuery

func (me *Handler) FileMatchesQuery(fileHash, query string) bool

func (*Handler) FileNameByHash

func (me *Handler) FileNameByHash(fileHash string, fromMetaOnly bool, spUrl string) string

func (*Handler) HasThumbnail

func (me *Handler) HasThumbnail(spUrl, fileHash string) bool

Only checking on disk

func (*Handler) NotifyLastState

func (me *Handler) NotifyLastState()

func (*Handler) PrepareRegister

func (me *Handler) PrepareRegister(reg Register, publicKeys [][]byte) (EncryptedArchive, error)

Prepare the files on the filesystem but doesn't do anything with it yet. Use PrepareRegisterAndScheduleUpload if you want to schedule an upload too

func (*Handler) PrepareRegisterAndScheduleUpload

func (me *Handler) PrepareRegisterAndScheduleUpload(reg Register, publicKeys [][]byte, spUrl string) (encryptedArchive EncryptedArchive, err error)

Prepares the files on disk and schedules an upload

func (*Handler) ReEncryptFile

func (me *Handler) ReEncryptFile(spUrl, fileHash string, pgpPubKeys [][]byte) (string, error)

func (*Handler) Register

func (me *Handler) Register(txHash, fileHash string, rdyForUpload bool) error

func (*Handler) RemoveFileAndMetaFromDisk

func (me *Handler) RemoveFileAndMetaFromDisk(fileHash string)

func (*Handler) RemoveFileFromDiskKeepMeta

func (me *Handler) RemoveFileFromDiskKeepMeta(fileHash string)

func (*Handler) RemovePlainFromDisk

func (me *Handler) RemovePlainFromDisk(fileHash, filename string) error

func (*Handler) RequestFileFromSpp

func (me *Handler) RequestFileFromSpp(spUrl, fileHash string) (string, error)

download from spp

func (*Handler) SetListener

func (me *Handler) SetListener(f func(stype, fhash, spUrl, txHash, status, name string, percentage float32) error, notificationManager *notification.Manager, chanHub *channelhub.ChannelHub)

func (*Handler) Thumbnail

func (me *Handler) Thumbnail(spUrl, fileHash string, fromCacheOnly bool) (string, error)

func (*Handler) TryDownload

func (me *Handler) TryDownload(spUrl, fileHash string)

Tries only if the download isn't scheduled already

type Pending

type Pending struct {
	CurrentAddress  string
	ArchiveFilePath string
	ReadyForUpload  bool
	UploadedToSPP   bool
	FileName        string
	TxHash          string
	SpAddress       string
	SpUrl           string
	FileHash        string
	Percentage      float32
	DurationDays    int
}

type Register

type Register struct {
	StorageProviderAddress string
	FileReader             io.Reader
	FileName               string
	FileKind               int
	FileSize               int64
	ThumbReader            io.Reader
	ThumbName              string
	DurationDays           int
}

type ReqFile

type ReqFile struct {
	Account  *account.Account
	SpUrl    string
	FileHash string
}

type TransferProgressCallback

type TransferProgressCallback func(float32)

type Uploader

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

func NewUploader

func NewUploader(cfg *config.Configuration, accountGetter func() *account.Account, waitWorkerGrp *sync.WaitGroup, closing *bool, stopAll *chan bool,
	uploadDownloadSync *map[string]*uploadDownloadStatus, uploadDownloadSyncMutex *sync.Mutex, wallet *account.Wallet, userAccountDir string) (*Uploader, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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