Documentation ¶
Index ¶
- type FS
- type ID
- type Node
- type Nodes
- func (nodes *Nodes) ByPath(path string) (*Node, error)
- func (nodes *Nodes) CheckEventualConsistency() error
- func (nodes *Nodes) CheckInvariants() error
- func (nodes *Nodes) Children(parent *Node) map[ID]*Node
- func (nodes *Nodes) MarkAsScanned(node *Node)
- func (nodes *Nodes) Path(doc *Node) string
- func (nodes *Nodes) PrintTree()
- func (nodes *Nodes) Root() *Node
- func (nodes *Nodes) Upsert(n *Node)
- type Status
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 (ie, the synchronized directory).
type Node ¶
type Node struct { ID ID Ino uint64 // 0 means unknown ParentID ID Name string Type types.Type Status Status }
Node is a file or directory on the local file system.
We don't use the inode number as the main identifier, as inode numbers can be reused on Linux, and we may want to says that two files (with two inode numbers) are the same like when saving a file by using a temporary file.
type Nodes ¶
type Nodes struct { ByID map[ID]*Node ByParentID map[ID]map[ID]*Node // parentID -> map of children ByIno map[uint64]*Node }
Nodes is keeping the information about the files in the synchronized directory of the local file system.
func NewNodes ¶
func NewNodes() *Nodes
NewNodes creates a new state for managing nodes (data about files or directories on the local file system).
func (*Nodes) CheckEventualConsistency ¶
CheckEventualConsistency checks properties that should be true if a stable nodes is reached, ie when no changes are made to the local file system, and we wait that the desktop client says it is synchronized. Then, properties like all nodes have a type that is file or directory, not unknown, should be true.
func (*Nodes) CheckInvariants ¶
CheckInvariants checks a few properties that should always be true. It can be used to detect bugs in the nodes.Local implementation.
func (*Nodes) Children ¶
Children returns a map of id -> node for the children of the given directory.
func (*Nodes) MarkAsScanned ¶
type Status ¶
type Status int
Status describes what operations are in progress on a node to improve the knowledge we have of it. For a directory, we can scan it to find what are its children.
const ( // InitialStatus is the default status of a new node InitialStatus Status = iota // ScanningStatus means that we are looking for the direct children of a directory ScanningStatus // ScannedStatus means that we know the direct children, but not yet the nodes below them ScannedStatus // StableStatus means that that the information about this node is reliable StableStatus )