versioner

package
v1.2.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: MPL-2.0 Imports: 19 Imported by: 5

Documentation

Overview

Package versioner implements common interfaces for file versioning and a simple default versioning scheme.

Index

Constants

View Source
const (
	TimeFormat = "20060102-150405"
	TimeGlob   = "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]" // glob pattern matching TimeFormat
)

Variables

View Source
var ErrRestorationNotSupported = fmt.Errorf("version restoration not supported with the current versioner")
View Source
var Factories = map[string]func(folderID string, filesystem fs.Filesystem, params map[string]string) Versioner{}

Functions

func ExtractTag added in v0.14.44

func ExtractTag(path string) string

Returns the tag from a filename, whether at the end or middle.

func TagFilename added in v0.14.44

func TagFilename(name, tag string) string

Inserts ~tag just before the extension of the filename.

func UntagFilename added in v0.14.44

func UntagFilename(path string) (string, string)

Types

type External

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

func (External) Archive

func (v External) Archive(filePath string) error

Archive moves the named file away to a version archive. If this function returns nil, the named file does not exist any more (has been archived).

func (External) GetVersions added in v1.1.4

func (v External) GetVersions() (map[string][]FileVersion, error)

func (External) Restore added in v1.1.4

func (v External) Restore(filePath string, versionTime time.Time) error

type FileVersion added in v0.14.44

type FileVersion struct {
	VersionTime time.Time `json:"versionTime"`
	ModTime     time.Time `json:"modTime"`
	Size        int64     `json:"size"`
}

type Interval

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

type Simple

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

func (Simple) Archive

func (v Simple) Archive(filePath string) error

Archive moves the named file away to a version archive. If this function returns nil, the named file does not exist any more (has been archived).

func (Simple) GetVersions added in v1.1.4

func (v Simple) GetVersions() (map[string][]FileVersion, error)

func (Simple) Restore added in v1.1.4

func (v Simple) Restore(filepath string, versionTime time.Time) error

type Staggered

type Staggered struct {
	suture.Service
	// contains filtered or unexported fields
}

func (*Staggered) Archive

func (v *Staggered) Archive(filePath string) error

Archive moves the named file away to a version archive. If this function returns nil, the named file does not exist any more (has been archived).

func (*Staggered) GetVersions added in v1.1.4

func (v *Staggered) GetVersions() (map[string][]FileVersion, error)

func (*Staggered) Restore added in v1.1.4

func (v *Staggered) Restore(filepath string, versionTime time.Time) error

type Trashcan

type Trashcan struct {
	suture.Service
	// contains filtered or unexported fields
}

func (*Trashcan) Archive

func (t *Trashcan) Archive(filePath string) error

Archive moves the named file away to a version archive. If this function returns nil, the named file does not exist any more (has been archived).

func (*Trashcan) GetVersions added in v1.1.4

func (t *Trashcan) GetVersions() (map[string][]FileVersion, error)

func (*Trashcan) Restore added in v1.1.4

func (t *Trashcan) Restore(filepath string, versionTime time.Time) error

func (*Trashcan) String

func (t *Trashcan) String() string

type Versioner

type Versioner interface {
	Archive(filePath string) error
	GetVersions() (map[string][]FileVersion, error)
	Restore(filePath string, versionTime time.Time) error
}

func NewExternal

func NewExternal(folderID string, filesystem fs.Filesystem, params map[string]string) Versioner

func NewSimple

func NewSimple(folderID string, folderFs fs.Filesystem, params map[string]string) Versioner

func NewStaggered

func NewStaggered(folderID string, folderFs fs.Filesystem, params map[string]string) Versioner

func NewTrashcan

func NewTrashcan(folderID string, folderFs fs.Filesystem, params map[string]string) Versioner

Jump to

Keyboard shortcuts

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