gdrive

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileExist = errors.New("file exist")

Functions

This section is empty.

Types

type Config

type Config struct {
	LocalFolderRoot  string
	RemoteFolderRoot string
	TotalMaxSize     int64 // in bytes
}

type Dao

type Dao interface {
	InsertOrUpdate(ctx context.Context, fileInfo *FileInfo) error
	Touch(ctx context.Context, filepathName string, date time.Time) error
	Delete(ctx context.Context, filepathName string) error
	TotalSize(ctx context.Context) (int64, error)
	QueryOldest(ctx context.Context, limit int) ([]FileInfo, error)
}

type FileInfo

type FileInfo struct {
	FileID     string
	LastAccess time.Time // time when the cache created
	Filepath   string
	Size       int64
	MimeType   string
}

type FileInsertInfo

type FileInsertInfo struct {
	FileBytes []byte
	Filepath  string
	Replace   bool
}

type GDrive

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

func New

func New(ctx context.Context, credential json.RawMessage, config *Config, dao Dao, token *oauth2.Token) (*GDrive, error)

func (*GDrive) ExchangeOauthCode

func (g *GDrive) ExchangeOauthCode(code string) (*oauth2.Token, error)

func (*GDrive) GetLoginURL

func (g *GDrive) GetLoginURL() string

func (*GDrive) Init

func (g *GDrive) Init() error

func (*GDrive) Start

func (g *GDrive) Start()

func (*GDrive) StoreFile

func (g *GDrive) StoreFile(ctx context.Context, fileInsertInfo *FileInsertInfo) error

func (*GDrive) TouchFile

func (g *GDrive) TouchFile(ctx context.Context, filePathName string) error

func (*GDrive) UploadAll

func (g *GDrive) UploadAll(ctx context.Context) error

type Memory

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

func NewMemoryDao

func NewMemoryDao() *Memory

func (*Memory) Delete

func (m *Memory) Delete(ctx context.Context, filepathName string) error

func (*Memory) InsertOrUpdate

func (m *Memory) InsertOrUpdate(ctx context.Context, fileInfo *FileInfo) error

func (*Memory) QueryOldest

func (m *Memory) QueryOldest(ctx context.Context, limit int) ([]FileInfo, error)

func (*Memory) TotalSize

func (m *Memory) TotalSize(ctx context.Context) (int64, error)

func (*Memory) Touch

func (m *Memory) Touch(ctx context.Context, filepathName string, date time.Time) error

Jump to

Keyboard shortcuts

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