core

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MB = 1000 * 1000
	GB = 1000 * 1000 * 1000
	TB = 1000 * 1000 * 1000 * 1000
	PB = 1000 * 1000 * 1000 * 1000 * 1000
	EB = 1000 * 1000 * 1000 * 1000 * 1000 * 1000
)
View Source
const (
	MsgAppTitleExtra = "AppTitleExtra"

	MsgDaysLong     = "DaysLong"
	MsgDaysShort    = "DaysShort"
	MsgHoursLong    = "HoursLong"
	MsgHoursShort   = "HoursShort"
	MsgMinutesLong  = "MinutesLong"
	MsgMinutesShort = "MinutesShort"
	MsgSecondsLong  = "SecondsLong"
	MsgSecondsShort = "SecondsShort"

	MsgBytesLong      = "BytesLong"
	MsgBytesShort     = "BytesShort"
	MsgKiloBytesLong  = "KiloBytesLong"
	MsgKiloBytesShort = "KiloBytesShort"
	MsgMegaBytesLong  = "MegaBytesLong"
	MsgMegaBytesShort = "MegaBytesShort"
	MsgGigaBytesLong  = "GigaBytesLong"
	MsgGigaBytesShort = "GigaBytesShort"
	MsgTeraBytesLong  = "TeraBytesLong"
	MsgTeraBytesShort = "TeraBytesShort"
	MsgPetaBytesLong  = "PetaBytesLong"
	MsgPetaBytesShort = "PetaBytesShort"
	MsgExaBytesLong   = "ExaBytesLong"
	MsgExaBytesShort  = "ExaBytesShort"
)

Variables

View Source
var (
	APP_ID                = "org.d2r2.gorsync"
	SETTINGS_ID           = APP_ID + ".Settings"
	SETTINGS_PROFILE_ID   = SETTINGS_ID + ".Profile"
	SETTINGS_PROFILE_PATH = "/org/d2r2/gorsync/profiles/%s/"
	SETTINGS_SOURCE_ID    = SETTINGS_PROFILE_ID + ".Source"
	SETTINGS_SOURCE_PATH  = "/org/d2r2/gorsync/profiles/%s/sources/%s/"
)

Functions

func FindStringSubmatchIndexes

func FindStringSubmatchIndexes(re *regexp.Regexp, s string) map[string][2]int

func FormatDurationToDaysHoursMinsSecs

func FormatDurationToDaysHoursMinsSecs(dur time.Duration, short bool, sections *int) string

FormatDurationToDaysHoursMinsSecs print time span in the format "x1 day(s) x2 hour(s) x3 minute(s) x4 second(s)". Understand plural cases for right spellings. Might be limited to number of sections.

func FormatSize

func FormatSize(byteCount uint64, short bool) string

func GetAppArchitecture

func GetAppArchitecture() string

func GetAppExtraTitle

func GetAppExtraTitle() string

func GetAppFullTitle

func GetAppFullTitle() string

func GetAppTitle

func GetAppTitle() string

func GetAppVersion

func GetAppVersion() string

func GetGolangVersion

func GetGolangVersion() string

func GetReadableSize

func GetReadableSize(size FolderSize) string

func GetRelativePath

func GetRelativePath(rootDest, destPath string) (string, error)

GetRelativePath cut off root prefix from destPath (if found).

func GetRelativePaths

func GetRelativePaths(rootDest string, paths []string) ([]string, error)

GetRelativePaths cut off root prefix from multiple paths (if found).

func MegabytesToBytes

func MegabytesToBytes(size uint64) uint64

func Round

func Round(x float64) float64

Round returns the nearest integer, rounding ties away from zero.

func RsyncPathJoin

func RsyncPathJoin(elements ...string) string

RsyncPathJoin used to join path elements in RSYNC url.

func RunExecutableWithExtraVars

func RunExecutableWithExtraVars(path string, env []string, args ...string) (error, int)

func SetBuildNum

func SetBuildNum(buildnum string)

func SetVersion

func SetVersion(version string)

func SplitByEOL

func SplitByEOL(text string) []string

Types

type Dir

type Dir struct {
	Paths   SrcDstPath
	Name    string
	Parent  *Dir
	Childs  []*Dir
	Metrics DirMetrics
}

Dir is a "tree data structure" to describe folder's tree received from the source in 1st pass of backup process to measure counts/sizes and to predict time necessary for backup process (ETA).

func BuildDirTree

func BuildDirTree(paths SrcDstPath, ignoreBackupFileSigName string) (*Dir, error)

func (*Dir) GetContentBackupSize

func (v *Dir) GetContentBackupSize() FolderSize

func (*Dir) GetFoldersCount

func (v *Dir) GetFoldersCount() int

func (*Dir) GetFoldersIgnoreCount

func (v *Dir) GetFoldersIgnoreCount() int

func (*Dir) GetFullBackupSize

func (v *Dir) GetFullBackupSize() FolderSize

func (*Dir) GetIgnoreSize

func (v *Dir) GetIgnoreSize() FolderSize

func (*Dir) GetTotalSize

func (v *Dir) GetTotalSize() FolderSize

type DirMetrics

type DirMetrics struct {
	// Define depth from root folder. Root folder has Depth = 0.
	Depth int
	// Total count of all child folders.
	ChildrenCount int
	// "Size" metric defines summary size of all local files,
	// do not include any child folders.
	Size *FolderSize
	// "Full size" metric, which include all files and
	// child folders with their content.
	FullSize *FolderSize
	// Flag which means, that folder contain special file
	// which serves as tag to do not backup this folder.
	IgnoreToBackup bool
	// Flag which means, that this folder already marked
	// as "measured" in traverse path search.
	Measured bool
	// Type of backup for current folder defined
	// as a result of traverse path search.
	BackupType FolderBackupType
}

DirMetrics keeps metrics defined in 1st pass of folders tree. Metrics used lately in heuristic algorithm to find optimal folder tree traverse.

type FolderBackupType

type FolderBackupType int
const (
	FBT_UNKNOWN FolderBackupType = iota
	FBT_SKIP
	FBT_RECURSIVE
	FBT_CONTENT
)

func (FolderBackupType) String

func (v FolderBackupType) String() string

type FolderSize

type FolderSize int64

func NewFolderSize

func NewFolderSize(size int64) FolderSize

func (FolderSize) Add

func (v FolderSize) Add(value FolderSize) FolderSize

func (FolderSize) AddSizeProgress

func (v FolderSize) AddSizeProgress(value SizeProgress) FolderSize

func (FolderSize) GetByteCount

func (v FolderSize) GetByteCount() uint64

type ProxyLog

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

func NewProxyLog

func NewProxyLog(child logger.PackageLog, packageName string, packageLen int,
	timeFormat string, writeLine WriteLine, customLogLevel logger.LogLevel) *ProxyLog

func (*ProxyLog) Debug

func (v *ProxyLog) Debug(args ...interface{})

func (*ProxyLog) Debugf

func (v *ProxyLog) Debugf(format string, args ...interface{})

func (*ProxyLog) Error

func (v *ProxyLog) Error(args ...interface{})

func (*ProxyLog) Errorf

func (v *ProxyLog) Errorf(format string, args ...interface{})

func (*ProxyLog) Fatal

func (v *ProxyLog) Fatal(args ...interface{})

func (*ProxyLog) Fatalf

func (v *ProxyLog) Fatalf(format string, args ...interface{})

func (*ProxyLog) Info

func (v *ProxyLog) Info(args ...interface{})

func (*ProxyLog) Infof

func (v *ProxyLog) Infof(format string, args ...interface{})

func (*ProxyLog) Notify

func (v *ProxyLog) Notify(args ...interface{})

func (*ProxyLog) Notifyf

func (v *ProxyLog) Notifyf(format string, args ...interface{})

func (*ProxyLog) Panic

func (v *ProxyLog) Panic(args ...interface{})

func (*ProxyLog) Panicf

func (v *ProxyLog) Panicf(format string, args ...interface{})

func (*ProxyLog) Print

func (v *ProxyLog) Print(level logger.LogLevel, args ...interface{})

func (*ProxyLog) Printf

func (v *ProxyLog) Printf(level logger.LogLevel, format string, args ...interface{})

func (*ProxyLog) Warn

func (v *ProxyLog) Warn(args ...interface{})

func (*ProxyLog) Warnf

func (v *ProxyLog) Warnf(format string, args ...interface{})

func (*ProxyLog) Warning

func (v *ProxyLog) Warning(args ...interface{})

func (*ProxyLog) Warningf

func (v *ProxyLog) Warningf(format string, args ...interface{})

type SizeProgress

type SizeProgress struct {
	Completed *FolderSize
	Skipped   *FolderSize
	Failed    *FolderSize
}

func NewProgressCompleted

func NewProgressCompleted(size FolderSize) SizeProgress

func NewProgressFailed

func NewProgressFailed(size FolderSize) SizeProgress

func NewProgressSkipped

func NewProgressSkipped(size FolderSize) SizeProgress

func (*SizeProgress) Add

func (this *SizeProgress) Add(size SizeProgress)

func (*SizeProgress) GetTotal

func (this *SizeProgress) GetTotal() FolderSize

type SrcDstPath

type SrcDstPath struct {
	RsyncSourcePath string
	DestPath        string
}

SrcDstPath link to each other RSYNC source URL with destination extra path added to backup folder.

func (SrcDstPath) Join

func (v SrcDstPath) Join(item string) SrcDstPath

Join fork SrcDstPath with new variant, where new "folder" amended to the end of the path.

type WriteLine

type WriteLine func(line string) error

Source Files

  • abstract.go
  • common.go
  • dir.go
  • format.go
  • info.go
  • messagekeys.go
  • path.go
  • proxylog.go
  • utils.go

Jump to

Keyboard shortcuts

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