drive_db

package
v0.0.0-...-1d0b4aa Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckPoint

type CheckPoint struct {
	LastChangeID int64
	LastInode    uint64
	Version      int
	CacheBlock   int64
}

func NewCheckpoint

func NewCheckpoint() CheckPoint

type DownloadSpec

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

type DownloadURL

type DownloadURL struct {
	URL  string
	When int64 // epoch time
}

type DriveDB

type DriveDB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDriveDB

func NewDriveDB(client *http.Client, dbPath, cachePath string, pollInterval time.Duration, rootId string) (*DriveDB, error)

NewDriveDB creates a new DriveDB and starts syncing metadata.

func (*DriveDB) AllFileIds

func (d *DriveDB) AllFileIds() ([]string, error)

AllFileIds returns the IDs of all Google Drive file objects currently stored.

func (*DriveDB) Close

func (d *DriveDB) Close()

Close closes DriveDB, waiting until all iterators are closed.

func (*DriveDB) CloseFile

func (d *DriveDB) CloseFile(fileId string)

func (*DriveDB) FileByFileId

func (d *DriveDB) FileByFileId(fileId string) (*File, error)

FileByFileId returns a *File given a fileId

func (*DriveDB) FileById

func (d *DriveDB) FileById(fileId string) (*gdrive.File, error)

FileById returns a File, given its ID.

func (*DriveDB) FileByInode

func (d *DriveDB) FileByInode(inode uint64) (*File, error)

FileByInode returns a *File given an inode number

func (*DriveDB) FileIdForInode

func (d *DriveDB) FileIdForInode(inode uint64) (string, error)

FileIdForInode returns the FileId associated with a given inode.

func (*DriveDB) FlushCachedInode

func (d *DriveDB) FlushCachedInode(inode uint64)

func (*DriveDB) FlushCachedInodeForFileId

func (d *DriveDB) FlushCachedInodeForFileId(fileId string)

func (*DriveDB) InodeForFileId

func (d *DriveDB) InodeForFileId(fileId string) (uint64, error)

InodeForFileId returns a File's inode number, given its ID. Allocates a new inode number if needed, and commits immediately to leveldb.

func (*DriveDB) IsOpen

func (d *DriveDB) IsOpen(fileId string) bool

func (*DriveDB) OpenFile

func (d *DriveDB) OpenFile(fileId string)

func (*DriveDB) ReadFiledata

func (d *DriveDB) ReadFiledata(f *File, offset, size, filesize int64) ([]byte, error)

ReadFiledata reads a chunk of a file, possibly from cache.

func (*DriveDB) Refresh

func (d *DriveDB) Refresh(fileId string) (*File, error)

Refresh the file object of the given fileId

func (*DriveDB) RemoveAllFiles

func (d *DriveDB) RemoveAllFiles() error

RemoveAllFiles removes all file entries and child references from leveldb. This also flushes the cache, but preserves the fileid->inode mapping

func (*DriveDB) RemoveFile

func (d *DriveDB) RemoveFile(f *gdrive.File) error

func (*DriveDB) RemoveFileById

func (d *DriveDB) RemoveFileById(fileId string, batch *leveldb.Batch) error

func (*DriveDB) Service

func (d *DriveDB) Service() *gdrive.Service

func (*DriveDB) UpdateFile

func (d *DriveDB) UpdateFile(batch *leveldb.Batch, f *gdrive.File) (*File, error)

UpdateFile commits a gdrive.File to levelDB, updating all mappings and allocating inodes if needed.

func (*DriveDB) WaitUntilSynced

func (d *DriveDB) WaitUntilSynced()

WaitUntilSynced blocks until are are synced with Drive.

type File

type File struct {
	*gdrive.File
	Inode     uint64
	Children  []uint64 // inodes of children
	LinkCount int
}

Jump to

Keyboard shortcuts

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