remote

package
v0.0.0-...-bb2c1c1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RootID is the id of the CouchDB document that represents the root on the
	// Cozy.
	RootID = "io.cozy.files.root-dir"
	// TrashID is the id of the CouchDB document that represents the trash on
	// the Cozy.
	TrashID = "io.cozy.files.trash-dir"
	// TrashName is the name of the trash folder on the Cozy.
	TrashName = ".cozy_trash"
	// Directory is the type of directories for the CouchDB documents on the
	// Cozy.
	Directory = "directory"
	// File is the type for, well, files for the CouchDB documents on the Cozy.
	File = "file"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangedDoc

type ChangedDoc struct {
	*Doc
	Deleted bool
}

ChangedDoc is a result item from the changes feed.

type ChangesResponse

type ChangesResponse struct {
	Docs    []*ChangedDoc
	Seq     Seq
	Pending int
}

ChangesResponse describes the successful response to a call to the changes feed.

type Client

type Client interface {
	// Changes is used to request the changes feed since a sequence number.
	Changes(seq *Seq, limit int, skipTrashed bool) (*ChangesResponse, error)

	// CreateDir will create a directory on the Cozy.
	CreateDir(parentID ID, name string) (*Doc, error)

	// Trash will put a file or directory inside the trash on the Cozy.
	Trash(doc *Doc) (*Doc, error)

	// EmptyTrash will delete the files and directories in the trash. Useful
	// for tests.
	EmptyTrash() error

	// Refresh can be used to refresh the OAuth access token.
	Refresh() error

	// Synchronized can be called to inform the Cozy that the client is now
	// synchronized. The data of last synchronization is shown in
	// cozy-settings.
	Synchronized() error
}

Client is an interface for a client that can make requests to the cozy-stack to manipulate files.

type Doc

type Doc struct {
	ID    ID
	Rev   Rev
	Type  types.Type
	Name  string
	DirID ID
}

Doc describes a CouchDB document for the io.cozy.files doctype on the Cozy.

type Docs

type Docs struct {
	ByID            map[ID]*Doc
	ByDirID         map[ID]map[ID]*Doc // dirID -> map of children
	Seq             *Seq
	FetchingChanges bool
	Refreshing      bool
	RefreshedAt     types.Clock
	SynchronizedAt  types.Clock
}

Docs is keeping the information about the files on the Cozy.

func NewDocs

func NewDocs() *Docs

NewDocs creates a new docs.

func (*Docs) Children

func (docs *Docs) Children(parent *Doc) map[ID]*Doc

Children returns a map of ID -> doc for the children of the given doc.

func (*Docs) MarkAsDeleted

func (docs *Docs) MarkAsDeleted(id ID)

MarkAsDeleted is used to mark a document as deleted.

func (*Docs) Upsert

func (docs *Docs) Upsert(doc *Doc)

Upsert will add or update the given doc in the docs.

type ID

type ID string

ID is used for identifying the CouchDB documents.

func (ID) IsDesignDoc

func (id ID) IsDesignDoc() bool

IsDesignDoc returns true if the id is reserved for a design document.

type Rev

type Rev string

Rev is used by CouchDB to avoid conflicts.

type Seq

type Seq string

Seq is the short for sequence. It is a way to keep a position on the changes feed for the next calls.

func (Seq) ExtractGeneration

func (s Seq) ExtractGeneration() int

ExtractGeneration returns the first part of a sequence. The generation is the number before the "-".

Jump to

Keyboard shortcuts

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