reposnapshot

package
v2.29.7 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionOnNodeFunc

type ActionOnNodeFunc func(node *Node) error

type Node

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

Represents a directory in the repo state snapshot.

func CreateNewNode

func CreateNewNode(dirName string, parent *Node) *Node

func (*Node) AddChildNode

func (node *Node) AddChildNode(dirName string, childrenMapPool map[string]*Node) error

Adds a new child node to children map. childrenMapPool - [Optional] Children map to check existence of a dirName in before creating a new node.

func (*Node) AddFile

func (node *Node) AddFile(fileName string, size int64) error

func (*Node) CheckCompleted

func (node *Node) CheckCompleted() error

Check if node completed - if done exploring, done handling files, children are completed.

func (*Node) FileCompleted

func (node *Node) FileCompleted(fileName string) error

func (*Node) GetChildren

func (node *Node) GetChildren() (children map[string]*Node, err error)

func (*Node) GetFiles

func (node *Node) GetFiles() (filesMap map[string]int64, err error)

func (*Node) IsCompleted

func (node *Node) IsCompleted() (completed bool, err error)

func (*Node) IsDoneExploring

func (node *Node) IsDoneExploring() (doneExploring bool, err error)

func (*Node) MarkDoneExploring

func (node *Node) MarkDoneExploring() error

Marks that all contents of the node have been found and added.

func (*Node) RestartExploring

func (node *Node) RestartExploring() error

type NodeExportWrapper

type NodeExportWrapper struct {
	Name               string                        `json:"name,omitempty"`
	Children           map[string]*NodeExportWrapper `json:"children,omitempty"`
	FilesNamesAndSizes map[string]int64              `json:"files,omitempty"`
	Completed          bool                          `json:"completed,omitempty"`
	DoneExploring      bool                          `json:"done_exploring,omitempty"`
}

Used to export/load the node tree to/from a file. Wrapper is needed since fields on the original node are unexported (to avoid operations that aren't thread safe). In addition, wrapper does not hold the parent pointer to avoid cyclic reference on export.

type RepoSnapshotManager

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

Represents a snapshot of a repository being traversed to do a certain action. Each directory in the repository is represented by a node. The snapshot is constructed as a linked prefix tree, where every node has pointers to its children and parent. While traversing over the repository, contents found are added to their respecting node. Later on, files handled are removed from their node. Each node has one of three states:

  1. Unexplored / Partially explored - NOT all contents of the directory were found and added to its node (Marked by !DoneExploring).
  2. Fully explored - All contents of the directory were found, but NOT all of them handled (Marked by DoneExploring && !Completed).
  3. Completed - All contents found and handled (Marked by Completed).

In the event of a node reaching completion, a tree collapsing may occur in order to save space: The node will mark itself completed, and will then notify the parent to check completion as well.

func CreateRepoSnapshotManager

func CreateRepoSnapshotManager(repoKey, snapshotFilePath string) RepoSnapshotManager

func LoadRepoSnapshotManager

func LoadRepoSnapshotManager(repoKey, snapshotFilePath string) (RepoSnapshotManager, bool, error)

Loads a repo snapshot from the provided snapshotFilePath if such file exists. If successful, returns the snapshot and exists=true.

func (*RepoSnapshotManager) GetDirectorySnapshotNodeWithLru

func (sm *RepoSnapshotManager) GetDirectorySnapshotNodeWithLru(relativePath string) (node *Node, err error)

Returns the node that represents the directory from the repo state. Updates the lru cache. relativePath - relative path of the directory.

func (*RepoSnapshotManager) LookUpNode

func (sm *RepoSnapshotManager) LookUpNode(relativePath string) (requestedNode *Node, err error)

Returns the node corresponding to the directory in the provided relative path. Path should be provided without the repository name.

func (*RepoSnapshotManager) PersistRepoSnapshot

func (sm *RepoSnapshotManager) PersistRepoSnapshot() error

Jump to

Keyboard shortcuts

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