sync15

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: AGPL-3.0 Imports: 26 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Delimiter = ':'
View Source
const DocType = "80000000"
View Source
const FileType = "0"
View Source
const ROOT_NAME = "root"
View Source
const SchemaVersion = "3"

Variables

This section is empty.

Functions

func DocumentsFileTree

func DocumentsFileTree(tree *HashTree) *filetree.FileTreeCtx

DocumentsFileTree reads your remote documents and builds a file tree structure to represent them

func FileHashAndSize

func FileHashAndSize(file string) ([]byte, int64, error)

func HashEntries

func HashEntries(entries []*Entry) (string, error)

func Sync

func Sync(b *BlobStorage, tree *HashTree, operation func(t *HashTree) error) error

Sync applies changes to the local tree and syncs with the remote storage

Types

type ApiCtx

type ApiCtx struct {
	Http *transport.HttpClientCtx
	// contains filtered or unexported fields
}

An ApiCtx allows you interact with the remote reMarkable API

func CreateCtx

func CreateCtx(http *transport.HttpClientCtx) (*ApiCtx, error)

func (*ApiCtx) CreateDir

func (ctx *ApiCtx) CreateDir(parentId, name string, notify bool) (*model.Document, error)

CreateDir creates a remote directory with a given name under the parentId directory

func (*ApiCtx) DeleteEntry

func (ctx *ApiCtx) DeleteEntry(node *model.Node) error

DeleteEntry removes an entry: either an empty directory or a file

func (*ApiCtx) FetchDocument

func (ctx *ApiCtx) FetchDocument(docId, dstPath string) error

FetchDocument downloads a document given its ID and saves it locally into dstPath

func (*ApiCtx) Filetree

func (ctx *ApiCtx) Filetree() *filetree.FileTreeCtx

func (*ApiCtx) MoveEntry

func (ctx *ApiCtx) MoveEntry(src, dstDir *model.Node, name string) (*model.Node, error)

MoveEntry moves an entry (either a directory or a file) - src is the source node to be moved - dstDir is an existing destination directory - name is the new name of the moved entry in the destination directory

func (*ApiCtx) Nuke

func (ctx *ApiCtx) Nuke() (err error)

Nuke removes all documents from the account

func (*ApiCtx) Refresh added in v0.0.23

func (ctx *ApiCtx) Refresh() error

func (*ApiCtx) SyncComplete added in v0.0.19

func (ctx *ApiCtx) SyncComplete() error

SyncComplete notfies that somethings has changed (triggers tablet sync)

func (*ApiCtx) UploadDocument

func (ctx *ApiCtx) UploadDocument(parentId string, sourceDocPath string, notify bool) (*model.Document, error)

UploadDocument uploads a local document given by sourceDocPath under the parentId directory

type BlobDoc

type BlobDoc struct {
	Files []*Entry
	Entry
	Metadata archive.MetadataFile
}

func NewBlobDoc

func NewBlobDoc(name, documentId, colType, parentId string) *BlobDoc

func (*BlobDoc) AddFile

func (d *BlobDoc) AddFile(e *Entry) error

func (*BlobDoc) IndexReader

func (d *BlobDoc) IndexReader() (io.ReadCloser, error)

func (*BlobDoc) Line

func (d *BlobDoc) Line() string

func (*BlobDoc) MetadataHashAndReader

func (d *BlobDoc) MetadataHashAndReader() (hash string, reader io.Reader, err error)

func (*BlobDoc) Mirror

func (d *BlobDoc) Mirror(e *Entry, r RemoteStorage) error

Mirror updates the document to be the same as the remote

func (*BlobDoc) ReadMetadata

func (d *BlobDoc) ReadMetadata(fileEntry *Entry, r RemoteStorage) error

ReadMetadata the document metadata from remote blob

func (*BlobDoc) Rehash

func (d *BlobDoc) Rehash() error

func (*BlobDoc) ToDocument

func (d *BlobDoc) ToDocument() *model.Document

type BlobStorage

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

func NewBlobStorage added in v0.0.23

func NewBlobStorage(http *transport.HttpClientCtx) *BlobStorage

func (*BlobStorage) GetReader

func (b *BlobStorage) GetReader(hash string) (io.ReadCloser, error)

func (*BlobStorage) GetRootIndex

func (b *BlobStorage) GetRootIndex() (string, int64, error)

func (*BlobStorage) GetUrl

func (b *BlobStorage) GetUrl(hash string) (string, error)

func (*BlobStorage) PutRootUrl added in v0.0.22

func (b *BlobStorage) PutRootUrl(hash string, gen int64) (string, int64, error)

func (*BlobStorage) PutUrl added in v0.0.17

func (b *BlobStorage) PutUrl(hash string) (string, int64, error)

func (*BlobStorage) SyncComplete

func (b *BlobStorage) SyncComplete(gen int64) error

SyncComplete notifies that the sync is done

func (*BlobStorage) UploadBlob

func (b *BlobStorage) UploadBlob(hash string, reader io.Reader) error

func (*BlobStorage) WriteRootIndex

func (b *BlobStorage) WriteRootIndex(roothash string, gen int64) (int64, error)

type Entry

type Entry struct {
	Hash       string
	Type       string
	DocumentID string
	Subfiles   int
	Size       int64
}

func (*Entry) Line

func (d *Entry) Line() string

type FieldReader

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

func NewFieldReader

func NewFieldReader(line string) FieldReader

func (*FieldReader) HasNext

func (fr *FieldReader) HasNext() bool

func (*FieldReader) Next

func (fr *FieldReader) Next() (string, error)

type HashTree

type HashTree struct {
	Hash         string
	Generation   int64
	Docs         []*BlobDoc
	CacheVersion int
}

func BuildTree

func BuildTree(provider RemoteStorage) (*HashTree, error)

func (*HashTree) Add

func (t *HashTree) Add(d *BlobDoc) error

func (*HashTree) FindDoc

func (t *HashTree) FindDoc(id string) (*BlobDoc, error)

func (*HashTree) IndexReader

func (t *HashTree) IndexReader() (io.ReadCloser, error)

func (*HashTree) Mirror

func (t *HashTree) Mirror(r RemoteStorage, maxconcurrent int) error

/ Mirror makes the tree look like the storage

func (*HashTree) Rehash

func (t *HashTree) Rehash() error

func (*HashTree) Remove

func (t *HashTree) Remove(id string) error

type RemoteStorage

type RemoteStorage interface {
	GetRootIndex() (hash string, generation int64, err error)
	GetReader(hash string) (io.ReadCloser, error)
}

type RemoteStorageWriter

type RemoteStorageWriter interface {
	UpdateRootIndex(hash string, generation int64) (gen int64, err error)
	GetWriter(hash string, writer io.WriteCloser) error
}

Jump to

Keyboard shortcuts

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