models

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DocumentType   = "DocumentType"
	CollectionType = "CollectionType"

	MetadataFileExt = ".metadata"
	PageFileExt     = ".pagedata"
	ContentFileExt  = ".content"
	RmFileExt       = ".rm"

	//ZipFileExt zip file extension
	ZipFileExt = ".zip"
	//EpubFileExt epub
	EpubFileExt = ".epub"
	//PdfFileExt pdf
	PdfFileExt = ".pdf"
)

Variables

This section is empty.

Functions

func ArchiveFromHashDoc

func ArchiveFromHashDoc(doc *HashDoc, rs RemoteStorage) (*exporter.MyArchive, error)

ArchiveFromHashDoc reads an archive

func FileHashAndSize

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

func Hash

func Hash(r io.Reader) (string, int64, error)

func HashEntries

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

Types

type FieldReader

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

FieldReader iterates over delimted fields

func NewFieldReader

func NewFieldReader(line string) FieldReader

NewFieldReader reader from string line

func (*FieldReader) HasNext

func (fr *FieldReader) HasNext() bool

HasNext are there more fields

func (*FieldReader) Next

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

Next read the next field

type HashDoc

type HashDoc struct {
	Files []*HashEntry
	HashEntry
	MetadataFile
}

HashDoc a document in a hash tree

func NewHashDoc

func NewHashDoc(name, documentID, colType string) *HashDoc

func NewHashDocMeta

func NewHashDocMeta(documentID string, meta MetadataFile) *HashDoc

func (*HashDoc) AddFile

func (d *HashDoc) AddFile(e *HashEntry) error

func (*HashDoc) IndexReader

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

IndexReader reader of the document index

func (*HashDoc) Line

func (d *HashDoc) Line() string

Line index line

func (*HashDoc) MetadataReader

func (d *HashDoc) MetadataReader() (hash string, reader io.Reader, err error)

func (*HashDoc) Mirror

func (d *HashDoc) Mirror(e *HashEntry, r RemoteStorage) error

Mirror mirror on the wall

func (*HashDoc) ReadMetadata

func (d *HashDoc) ReadMetadata(fileEntry *HashEntry, r RemoteStorage) error

ReadMetadata the documentname from metadata blob

func (*HashDoc) Rehash

func (d *HashDoc) Rehash() error

type HashEntry

type HashEntry struct {
	Hash      string
	Type      string
	EntryName string
	Subfiles  int
	Size      int64
}

HashEntry an entry with a hash

func NewFileHashEntry

func NewFileHashEntry(hash, documentID string) *HashEntry

NewFileHashEntry blah

func (*HashEntry) Line

func (d *HashEntry) Line() string

Line a line in the index file

type HashTree

type HashTree struct {
	Hash       string
	Generation int64
	Docs       []*HashDoc
}

HashTree a syncing concept for faster diffing

func BuildTree

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

BuildTree from remote storage

func LoadTree

func LoadTree(cacheFile string) (*HashTree, error)

LoadTree loads

func (*HashTree) Add

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

func (*HashTree) FindDoc

func (t *HashTree) FindDoc(documentID string) (*HashDoc, error)

FindDoc finds a document by its name

func (*HashTree) Mirror

func (t *HashTree) Mirror(r RemoteStorage) (changed bool, err error)

Mirror makes the tree look like the storage

func (*HashTree) Rehash

func (t *HashTree) Rehash() error

Rehash recalcualte the root hash from all docs

func (*HashTree) Remove

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

Remove removes

func (*HashTree) RootIndex

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

RootIndex reads the root index

func (*HashTree) Save

func (t *HashTree) Save(cacheFile string) error

Save saves

type MetadataFile

type MetadataFile struct {
	DocumentName     string `json:"visibleName"`
	CollectionType   string `json:"type"`
	Parent           string `json:"parent"`
	LastModified     string `json:"lastModified"`
	LastOpened       string `json:"lastOpened"`
	Version          int    `json:"version"`
	Pinned           bool   `json:"pinned"`
	Synced           bool   `json:"synced"`
	Modified         bool   `json:"modified"`
	Deleted          bool   `json:"deleted"`
	MetadataModified bool   `json:"metadatamodified"`
}

MetadataFile content

type RemoteStorage

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

RemoteStorage remote access

type RemoteStorageWriter

type RemoteStorageWriter interface {
	WriteRootIndex(hash string, generation int64) (gen int64, err error)
	Write(hash string, reader io.Reader) error
}

RemoteStorageWriter some writer

Jump to

Keyboard shortcuts

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