Documentation ¶
Overview ¶
Package sync implements directory tree syncing with patch files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCannotRemove = errors.New("sync: could not find a valid start to apply, try with empty dir")
ErrCannotRemove is returned if Dir could not find a valid start to apply, but cannot remove the directory.
Functions ¶
func Dir ¶
func Dir( treeDir, targetHash, patchDir string, treeHashes []string, excludePaths []string, canRemoveDir bool, ) error
Dir syncs the treeDir to the tree hash targetHash with patches from patchDir.
treeHashes is a list of intermediate tree hashes which must start with tree.EmptyHash and contain the targetHash. Synchronization happens by applying one patch file after another, iterating through the treeHashes array until the targetHash is found.
In order to find a suitable start, the tree hash of treeDir is calculated and treeHashes is searched for the result.
If no suitable start can be found and canRemoveDir is true, all contents of treeDir are removed and the patches are applied starting from tree.EmptyHash. Otherwise, ErrCannotRemove is returned.
Patch files (see patchfile package) are named after the outgoing (source) tree hash and must lead to the targetDir having the tree hash of the next treeHashes entry after they have been applied.
The paths given in excludePaths are excluded from all tree hash calculations.
Types ¶
This section is empty.