common

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID uint64

ID is a synthetic number for identifying a node.

const RootID ID = 1

RootID is the identifier for the root.

type Link struct {
	ID       ID
	LocalID  local.ID
	RemoteID remote.ID
	ParentID ID
	Name     string
	Type     types.Type
}

Link is the last known state of a file or directory that was common to a local node and a remote doc.

Note: I'm using identifiers, and not pointers, for the LocalID and RemoteID as I think it will be easier when we will have persistence.

type Links struct {
	ByID       map[ID]*Link
	ByParentID map[ID]map[ID]*Link // parentID -> map of children
	ByLocalID  map[local.ID]*Link
	ByRemoteID map[remote.ID]*Link
}

Links is keeping the information that links the local file system with the remote Cozy.

func NewLinks() *Links

NewLinks creates a new state.

func (*Links) Add

func (links *Links) Add(link *Link)

Add adds a link to the links state, ie it assign an id to it and indexes it.

func (*Links) CheckInvariants

func (links *Links) CheckInvariants() error

CheckInvariants can be used to detect some bugs by checking some properties that should always be true if links is manipulated as expected.

func (*Links) Children

func (links *Links) Children(parent *Link) map[ID]*Link

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

func (*Links) Root

func (links *Links) Root() *Link

Root returns the link between the local synchronized directory and the root of the Cozy.

Jump to

Keyboard shortcuts

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