Documentation
¶
Overview ¶
Package sync provides the core data structures and algorithms used by Mutagen. It does not provide facilities for data transport or session management, which are instead provided by the rsync and session packages, respectively.
Index ¶
- Variables
- func Reconcile(ancestor, alpha, beta *Entry) ([]*Change, []*Change, []*Change, []*Conflict)
- func Scan(root string, hasher hash.Hash, cache *Cache, ignores []string, ...) (*Entry, bool, bool, *Cache, IgnoreCache, error)
- func Transition(root string, transitions []*Change, cache *Cache, symlinkMode SymlinkMode, ...) ([]*Entry, []*Problem)
- func TransitionDependencies(transitions []*Change) (map[string][]byte, error)
- func ValidIgnorePattern(pattern string) bool
- type Archive
- func (*Archive) Descriptor() ([]byte, []int)
- func (a *Archive) EnsureValid() error
- func (m *Archive) GetRoot() *Entry
- func (*Archive) ProtoMessage()
- func (m *Archive) Reset()
- func (m *Archive) String() string
- func (m *Archive) XXX_DiscardUnknown()
- func (m *Archive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Archive) XXX_Merge(src proto.Message)
- func (m *Archive) XXX_Size() int
- func (m *Archive) XXX_Unmarshal(b []byte) error
- type Cache
- func (*Cache) Descriptor() ([]byte, []int)
- func (c *Cache) EnsureValid() error
- func (c *Cache) GenerateReverseLookupMap() (*ReverseLookupMap, error)
- func (m *Cache) GetEntries() map[string]*CacheEntry
- func (*Cache) ProtoMessage()
- func (m *Cache) Reset()
- func (m *Cache) String() string
- func (m *Cache) XXX_DiscardUnknown()
- func (m *Cache) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Cache) XXX_Merge(src proto.Message)
- func (m *Cache) XXX_Size() int
- func (m *Cache) XXX_Unmarshal(b []byte) error
- type CacheEntry
- func (*CacheEntry) Descriptor() ([]byte, []int)
- func (m *CacheEntry) GetDigest() []byte
- func (m *CacheEntry) GetMode() uint32
- func (m *CacheEntry) GetModificationTime() *timestamp.Timestamp
- func (m *CacheEntry) GetSize() uint64
- func (*CacheEntry) ProtoMessage()
- func (m *CacheEntry) Reset()
- func (m *CacheEntry) String() string
- func (m *CacheEntry) XXX_DiscardUnknown()
- func (m *CacheEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *CacheEntry) XXX_Merge(src proto.Message)
- func (m *CacheEntry) XXX_Size() int
- func (m *CacheEntry) XXX_Unmarshal(b []byte) error
- type Change
- func (*Change) Descriptor() ([]byte, []int)
- func (c *Change) EnsureValid() error
- func (m *Change) GetNew() *Entry
- func (m *Change) GetOld() *Entry
- func (m *Change) GetPath() string
- func (*Change) ProtoMessage()
- func (m *Change) Reset()
- func (m *Change) String() string
- func (m *Change) XXX_DiscardUnknown()
- func (m *Change) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Change) XXX_Merge(src proto.Message)
- func (m *Change) XXX_Size() int
- func (m *Change) XXX_Unmarshal(b []byte) error
- type Conflict
- func (*Conflict) Descriptor() ([]byte, []int)
- func (c *Conflict) EnsureValid() error
- func (m *Conflict) GetAlphaChanges() []*Change
- func (m *Conflict) GetBetaChanges() []*Change
- func (*Conflict) ProtoMessage()
- func (m *Conflict) Reset()
- func (m *Conflict) String() string
- func (m *Conflict) XXX_DiscardUnknown()
- func (m *Conflict) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Conflict) XXX_Merge(src proto.Message)
- func (m *Conflict) XXX_Size() int
- func (m *Conflict) XXX_Unmarshal(b []byte) error
- type Entry
- func (e *Entry) Copy() *Entry
- func (e *Entry) CopyShallow() *Entry
- func (*Entry) Descriptor() ([]byte, []int)
- func (e *Entry) EnsureValid() error
- func (e *Entry) Equal(other *Entry) bool
- func (m *Entry) GetContents() map[string]*Entry
- func (m *Entry) GetDigest() []byte
- func (m *Entry) GetExecutable() bool
- func (m *Entry) GetKind() EntryKind
- func (m *Entry) GetTarget() string
- func (*Entry) ProtoMessage()
- func (m *Entry) Reset()
- func (m *Entry) String() string
- func (m *Entry) XXX_DiscardUnknown()
- func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Entry) XXX_Merge(src proto.Message)
- func (m *Entry) XXX_Size() int
- func (m *Entry) XXX_Unmarshal(b []byte) error
- type EntryKind
- type IgnoreCache
- type IgnoreCacheKey
- type IgnoreVCSMode
- type Problem
- func (*Problem) Descriptor() ([]byte, []int)
- func (p *Problem) EnsureValid() error
- func (m *Problem) GetError() string
- func (m *Problem) GetPath() string
- func (*Problem) ProtoMessage()
- func (m *Problem) Reset()
- func (m *Problem) String() string
- func (m *Problem) XXX_DiscardUnknown()
- func (m *Problem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Problem) XXX_Merge(src proto.Message)
- func (m *Problem) XXX_Size() int
- func (m *Problem) XXX_Unmarshal(b []byte) error
- type Provider
- type ReverseLookupMap
- type SymlinkMode
Constants ¶
This section is empty.
Variables ¶
var DefaultVCSIgnores = []string{
".git/",
".svn/",
".hg/",
".bzr/",
"_darcs/",
}
DefaultVCSIgnores is the default set of ignores to use when ignoring VCS directories.
var EntryKind_name = map[int32]string{
0: "Directory",
1: "File",
2: "Symlink",
}
var EntryKind_value = map[string]int32{
"Directory": 0,
"File": 1,
"Symlink": 2,
}
var IgnoreVCSMode_name = map[int32]string{
0: "IgnoreVCSDefault",
1: "IgnoreVCS",
2: "PropagateVCS",
}
var IgnoreVCSMode_value = map[string]int32{
"IgnoreVCSDefault": 0,
"IgnoreVCS": 1,
"PropagateVCS": 2,
}
var SymlinkMode_name = map[int32]string{
0: "SymlinkDefault",
1: "SymlinkIgnore",
2: "SymlinkPortable",
3: "SymlinkPOSIXRaw",
}
var SymlinkMode_value = map[string]int32{
"SymlinkDefault": 0,
"SymlinkIgnore": 1,
"SymlinkPortable": 2,
"SymlinkPOSIXRaw": 3,
}
Functions ¶
func Reconcile ¶
Reconcile performs a recursive three-way merge and generates a list of changes for the ancestor, alpha, and beta, as well as a list of conflicts.
func Scan ¶
func Scan(root string, hasher hash.Hash, cache *Cache, ignores []string, ignoreCache IgnoreCache, symlinkMode SymlinkMode) (*Entry, bool, bool, *Cache, IgnoreCache, error)
Scan provides recursive filesystem scanning facilities for synchronization roots.
func Transition ¶
func Transition( root string, transitions []*Change, cache *Cache, symlinkMode SymlinkMode, recomposeUnicode bool, provider Provider, ) ([]*Entry, []*Problem)
Transition provides recursive filesystem transitioning facilities for synchronization roots, allowing the application of changes after reconciliation.
func TransitionDependencies ¶
TransitionDependencies analyzes a list of transitions and determines the file paths (and their corresponding digests) that will need to be provided in order to apply the transitions using Transition.
func ValidIgnorePattern ¶
ValidIgnorePattern checks whether or not a given pattern is a valid ignore specification.
Types ¶
type Archive ¶
type Archive struct { Root *Entry `protobuf:"bytes,1,opt,name=root,proto3" json:"root,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Archive is a wrapper around Entry that allows identification of non-existent roots when serializing. In-memory, a nil-Entry (that arrives without any error) represents an absence of content on the filesystem. Unfortunately, there is no way to represent that as an encoded message (an empty byte slice would successfully decode to an empty directory entry). By adding a level of indirection that allows for an unset root entry, we can encode Entry messages in a way that allows us to represent absence.
func (*Archive) Descriptor ¶
func (*Archive) EnsureValid ¶ added in v0.7.0
func (*Archive) ProtoMessage ¶
func (*Archive) ProtoMessage()
func (*Archive) XXX_DiscardUnknown ¶
func (m *Archive) XXX_DiscardUnknown()
func (*Archive) XXX_Marshal ¶
func (*Archive) XXX_Unmarshal ¶
type Cache ¶
type Cache struct { // Entries is a map from scan path to cache entry. Entries map[string]*CacheEntry `` /* 155-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Cache provides a store for file metadata and digets to allow for efficient rescans.
func (*Cache) Descriptor ¶
func (*Cache) EnsureValid ¶
EnsureValid ensures that Cache's invariants are respected.
func (*Cache) GenerateReverseLookupMap ¶ added in v0.5.0
func (c *Cache) GenerateReverseLookupMap() (*ReverseLookupMap, error)
GenerateReverseLookupMap creates a reverse lookup map from a cache.
func (*Cache) GetEntries ¶
func (m *Cache) GetEntries() map[string]*CacheEntry
func (*Cache) ProtoMessage ¶
func (*Cache) ProtoMessage()
func (*Cache) XXX_DiscardUnknown ¶
func (m *Cache) XXX_DiscardUnknown()
func (*Cache) XXX_Marshal ¶
func (*Cache) XXX_Unmarshal ¶
type CacheEntry ¶
type CacheEntry struct { // Mode stores the value of the Go os package's FileMode type. The meaning // of this value is defined to be stable (even if we'd have to implement its // computation ourselves when porting to another language), so it's safe to // use, and it's a relatively sane implementation based on POSIX mode bits. // This information is currently used in scans and transitions, but only the // type and executability bits are really used (or at least necessary) at // the moment. It's not clear whether or not we'll eventually need the other // permission bits, and it might be possible to get away with a type // enumeration instead. This might be easier than trying to replicate // FileMode values if moving to another language, though I'm not sure that // would be too difficult. But I suppose it's better to just have this // additional mode information available for the sake of generality and // extensibility. We can always drop it later, but we can't add it back. It // may (I'm not exactly sure how) come in useful if we want to implement // permission propagation or need a better change detection heuristic. At // the moment though, it's highly unlikely that we'll switch away from Go, // and I'm willing to live with this slightly "unclean" design, especially // given its potential and the relative ease of deprecating it if necessary. Mode uint32 `protobuf:"varint,1,opt,name=mode,proto3" json:"mode,omitempty"` // ModificationTime is the cached modification time. ModificationTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=modificationTime,proto3" json:"modificationTime,omitempty"` // Size is the cached size. Size uint64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` // Digest is the cached digest for file entries. Digest []byte `protobuf:"bytes,9,opt,name=digest,proto3" json:"digest,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
CacheEntry represents cache data for a file on disk.
func (*CacheEntry) Descriptor ¶
func (*CacheEntry) Descriptor() ([]byte, []int)
func (*CacheEntry) GetDigest ¶
func (m *CacheEntry) GetDigest() []byte
func (*CacheEntry) GetMode ¶
func (m *CacheEntry) GetMode() uint32
func (*CacheEntry) GetModificationTime ¶
func (m *CacheEntry) GetModificationTime() *timestamp.Timestamp
func (*CacheEntry) GetSize ¶
func (m *CacheEntry) GetSize() uint64
func (*CacheEntry) ProtoMessage ¶
func (*CacheEntry) ProtoMessage()
func (*CacheEntry) Reset ¶
func (m *CacheEntry) Reset()
func (*CacheEntry) String ¶
func (m *CacheEntry) String() string
func (*CacheEntry) XXX_DiscardUnknown ¶
func (m *CacheEntry) XXX_DiscardUnknown()
func (*CacheEntry) XXX_Marshal ¶
func (m *CacheEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*CacheEntry) XXX_Merge ¶
func (dst *CacheEntry) XXX_Merge(src proto.Message)
func (*CacheEntry) XXX_Size ¶
func (m *CacheEntry) XXX_Size() int
func (*CacheEntry) XXX_Unmarshal ¶
func (m *CacheEntry) XXX_Unmarshal(b []byte) error
type Change ¶
type Change struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` Old *Entry `protobuf:"bytes,2,opt,name=old,proto3" json:"old,omitempty"` New *Entry `protobuf:"bytes,3,opt,name=new,proto3" json:"new,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Change) Descriptor ¶
func (*Change) EnsureValid ¶
EnsureValid ensures that Change's invariants are respected.
func (*Change) ProtoMessage ¶
func (*Change) ProtoMessage()
func (*Change) XXX_DiscardUnknown ¶
func (m *Change) XXX_DiscardUnknown()
func (*Change) XXX_Marshal ¶
func (*Change) XXX_Unmarshal ¶
type Conflict ¶
type Conflict struct { AlphaChanges []*Change `protobuf:"bytes,1,rep,name=alphaChanges,proto3" json:"alphaChanges,omitempty"` BetaChanges []*Change `protobuf:"bytes,2,rep,name=betaChanges,proto3" json:"betaChanges,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Conflict) Descriptor ¶
func (*Conflict) EnsureValid ¶
EnsureValid ensures that Conflict's invariants are respected.
func (*Conflict) GetAlphaChanges ¶
func (*Conflict) GetBetaChanges ¶
func (*Conflict) ProtoMessage ¶
func (*Conflict) ProtoMessage()
func (*Conflict) XXX_DiscardUnknown ¶
func (m *Conflict) XXX_DiscardUnknown()
func (*Conflict) XXX_Marshal ¶
func (*Conflict) XXX_Unmarshal ¶
type Entry ¶
type Entry struct { // Kind encodes the type of filesystem entry being represented. Kind EntryKind `protobuf:"varint,1,opt,name=kind,proto3,enum=sync.EntryKind" json:"kind,omitempty"` // Contents represents a directory entry's contents. Contents map[string]*Entry `` /* 157-byte string literal not displayed */ // Digest represents the hash of a file entry's contents. Digest []byte `protobuf:"bytes,8,opt,name=digest,proto3" json:"digest,omitempty"` // Executable indicates whether or not a file entry is marked as executable. Executable bool `protobuf:"varint,9,opt,name=executable,proto3" json:"executable,omitempty"` // Target is the symlink target for symlink entries. Target string `protobuf:"bytes,12,opt,name=target,proto3" json:"target,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Entry represents a filesystem node (e.g. a directory, a file, or a symlink).
func Apply ¶
Apply applies a series of changes to a base entry. It's worth nothing that this function ignores the Old value for changes and that it assumes all changes are valid.
func PropagateExecutability ¶
PropagateExecutability propagates file executability from the ancestor and source to the target in a recursive fashion. Executability information is only propagated if entry paths, types, and contents match, with source taking precedent over ancestor.
func (*Entry) CopyShallow ¶
CopyShallow creates a shallow copy of the entry (excluding directory contents, if any).
func (*Entry) Descriptor ¶
func (*Entry) EnsureValid ¶
EnsureValid ensures that Entry's invariants are respected.
func (*Entry) Equal ¶
Equal determines whether or not another entry is entirely (recursively) equal to this one.
func (*Entry) GetContents ¶
func (*Entry) GetExecutable ¶
func (*Entry) ProtoMessage ¶
func (*Entry) ProtoMessage()
func (*Entry) XXX_DiscardUnknown ¶
func (m *Entry) XXX_DiscardUnknown()
func (*Entry) XXX_Marshal ¶
func (*Entry) XXX_Unmarshal ¶
type EntryKind ¶
type EntryKind int32
EntryKind encodes the type of entry represented by an Entry object.
func (EntryKind) EnumDescriptor ¶
type IgnoreCache ¶ added in v0.6.0
type IgnoreCache map[IgnoreCacheKey]bool
IgnoreCache provides an efficient mechanism to avoid recomputing ignores.
type IgnoreCacheKey ¶ added in v0.6.0
type IgnoreCacheKey struct {
// contains filtered or unexported fields
}
IgnoreCacheKey represents a key in an ignore cache.
type IgnoreVCSMode ¶
type IgnoreVCSMode int32
IgnoreVCSMode specifies the mode for ignoring VCS directories.
const ( // IgnoreVCSMode_IgnoreVCSDefault represents an unspecified VCS ignore // mode. It is not valid for use with Scan. It should be converted to one of // the following values based on the desired default behavior. IgnoreVCSMode_IgnoreVCSDefault IgnoreVCSMode = 0 // IgnoreVCSMode_IgnoreVCS indicates that VCS directories should be ignored. IgnoreVCSMode_IgnoreVCS IgnoreVCSMode = 1 // IgnoreVCSMode_PropagateVCS indicates that VCS directories should be // propagated. IgnoreVCSMode_PropagateVCS IgnoreVCSMode = 2 )
func (IgnoreVCSMode) Description ¶
func (m IgnoreVCSMode) Description() string
Description returns a human-readable description of a VCS ignore mode.
func (IgnoreVCSMode) EnumDescriptor ¶
func (IgnoreVCSMode) EnumDescriptor() ([]byte, []int)
func (IgnoreVCSMode) String ¶
func (x IgnoreVCSMode) String() string
func (IgnoreVCSMode) Supported ¶
func (m IgnoreVCSMode) Supported() bool
Supported indicates whether or not a particular VCS ignore mode is a valid, non-default value.
func (*IgnoreVCSMode) UnmarshalText ¶
func (m *IgnoreVCSMode) UnmarshalText(textBytes []byte) error
UnmarshalText implements the text unmarshalling interface used when loading from TOML files.
type Problem ¶
type Problem struct { Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*Problem) Descriptor ¶
func (*Problem) EnsureValid ¶
EnsureValid ensures that Problem's invariants are respected.
func (*Problem) ProtoMessage ¶
func (*Problem) ProtoMessage()
func (*Problem) XXX_DiscardUnknown ¶
func (m *Problem) XXX_DiscardUnknown()
func (*Problem) XXX_Marshal ¶
func (*Problem) XXX_Unmarshal ¶
type Provider ¶
type Provider interface { // Provide returns a filesystem path to a file containing the contents for // the path given as the first argument with the digest specified by the // second argument. Provide(path string, digest []byte) (string, error) }
Provider defines the interface that higher-level logic can use to provide files to transition algorithms.
type ReverseLookupMap ¶ added in v0.5.0
type ReverseLookupMap struct {
// contains filtered or unexported fields
}
ReverseLookupMap provides facilities for doing reverse lookups to avoid expensive staging operations in the case of renames and copies.
type SymlinkMode ¶
type SymlinkMode int32
SymlinkMode specifies the mode for handling the propagation of symlinks.
const ( // SymlinkMode_SymlinkDefault represents an unspecified symlink mode. It is // not valid for use with Scan or Transition. It should be converted to one // of the following values based on the desired default behavior. SymlinkMode_SymlinkDefault SymlinkMode = 0 // SymlinkMode_SymlinkIgnore specifies that all symlinks should be ignored. SymlinkMode_SymlinkIgnore SymlinkMode = 1 // SymlinkMode_SymlinkPortable specifies that only portable symlinks should // be synchronized. If a symlink is found during a scan operation that it is // not portable, it halts the scan and synchronization. The reason for this // is that it can't simply be ignored/unignored as desired without breaking // the three-way merge. SymlinkMode_SymlinkPortable SymlinkMode = 2 // SymlinkMode_SymlinkPOSIXRaw specifies that symlinks should be propagated // in their raw form. It is only valid on POSIX systems and only makes sense // in the context of POSIX-to-POSIX synchronization. SymlinkMode_SymlinkPOSIXRaw SymlinkMode = 3 )
func (SymlinkMode) Description ¶
func (m SymlinkMode) Description() string
Description returns a human-readable description of a symlink mode.
func (SymlinkMode) EnumDescriptor ¶
func (SymlinkMode) EnumDescriptor() ([]byte, []int)
func (SymlinkMode) String ¶
func (x SymlinkMode) String() string
func (SymlinkMode) Supported ¶
func (m SymlinkMode) Supported() bool
Supported indicates whether or not a particular symlink mode is a valid, non-default value.
func (*SymlinkMode) UnmarshalText ¶
func (m *SymlinkMode) UnmarshalText(textBytes []byte) error
UnmarshalText implements the text unmarshalling interface used when loading from TOML files.
Source Files
¶
- apply.go
- archive.go
- archive.pb.go
- cache.go
- cache.pb.go
- change.go
- change.pb.go
- conflict.go
- conflict.pb.go
- diff.go
- doc.go
- entry.go
- entry.pb.go
- executability.go
- ignore.go
- ignore.pb.go
- iterate.go
- modes.go
- path.go
- problem.go
- problem.pb.go
- reconcile.go
- scan.go
- stage.go
- symlink.go
- symlink.pb.go
- transition.go
- transition_posix.go