rsync

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgRsyncCallFailedError                  = "RsyncCallFailedError"
	MsgRsyncProcessTerminatedError           = "RsyncProcessTerminatedError"
	MsgRsyncCannotFindFolderSizeOutputError  = "RsyncCannotFindFolderSizeOutputError"
	MsgRsyncCannotParseFolderSizeOutputError = "RsyncCannotParseFolderSizeOutputError"
)
View Source
const RSYNC_CMD = "rsync"

RSYNC_CMD contains RSYNC console utility name to run.

Variables

This section is empty.

Functions

func GetPathStatus

func GetPathStatus(ctx context.Context, password *string,
	sourceRSync string, recursive bool) error

GetPathStatus verify that RSYNC source path is valid. For this RSYNC is launched, than exit status is evaluated.

func GetRsyncVersion

func GetRsyncVersion() (version string, protocol string, err error)

GetRsyncVersion run RSYNC to get version and protocol.

func IsInstalled

func IsInstalled() error

IsInstalled verify, that RSYNC application present in the system.

func IsRsyncCallFailedError

func IsRsyncCallFailedError(err error) bool

func IsRsyncProcessTerminatedError

func IsRsyncProcessTerminatedError(err error) bool

func NormalizeRsyncURL

func NormalizeRsyncURL(rsyncURL string) string

NormalizeRsyncURL normalize RSYNC URL by: 1) remove user specification (if found). 2) remove excess '/' chars in path following host.

func ObtainDirFullSize

func ObtainDirFullSize(ctx context.Context, password *string, dir *core.Dir,
	retryCount *int, log *Logging) (*core.FolderSize, error)

ObtainDirLocalSize parse STDOUT from RSYNC dry-run execution to extract full size of directory.

func ObtainDirLocalSize

func ObtainDirLocalSize(ctx context.Context, password *string, dir *core.Dir,
	retryCount *int, log *Logging) (*core.FolderSize, error)

ObtainDirLocalSize parse STDOUT from RSYNC dry-run execution to extract local size of directory without nested folders.

func RunRsyncWithRetry

func RunRsyncWithRetry(ctx context.Context, options *Options, log *Logging, stdOut *bytes.Buffer,
	paths core.SrcDstPath) (sessionErr, retryErr, criticalErr error)

RunRsyncWithRetry run RSYNC utility with retry attempts.

func WithDefaultParams

func WithDefaultParams(params []string) []string

Types

type ErrorHook

type ErrorHook struct {
	Call          ErrorHookCall
	PredictedSize *core.FolderSize
}

ErrorHook contains call and predicted size to work around RSYNC issues caused by out of disk space case.

func NewErrorHook

func NewErrorHook(call ErrorHookCall, predictedSize core.FolderSize) *ErrorHook

type ErrorHookCall

type ErrorHookCall func(err error, paths core.SrcDstPath, predictedSize *core.FolderSize,
	repeated int, retryLeft int) (newRetryLeft int, criticalError error)

ErrorHookCall is a delegate used to work around RSYNC issues caused by out of disk space case.

type Logging

type Logging struct {
	EnableLog          bool
	EnableIntensiveLog bool
	Log                logger.PackageLog
}

Logging keep settings whether we need to log RSYNC utility functioning. We can log only RSYNC calls, but also STDOUT output for intensive log.

type Options

type Options struct {
	RetryCount int
	Params     []string
	ErrorHook  *ErrorHook
	Password   *string
}

Options keep settings for RSYNC call. Settings include: retry count, parameters, ErrorHook object for recover attempt if issue thrown.

func NewOptions

func NewOptions(params []string) *Options

func (*Options) AddParams

func (v *Options) AddParams(params ...string) *Options

func (*Options) SetAuthPassword

func (v *Options) SetAuthPassword(password *string) *Options

func (*Options) SetErrorHook

func (v *Options) SetErrorHook(errorHook *ErrorHook) *Options

func (*Options) SetRetryCount

func (v *Options) SetRetryCount(retryCount *int) *Options

type RsyncCallFailedError

type RsyncCallFailedError struct {
	ExitCode    int
	Description string
}

RsyncCallFailedError denote a situation when RSYNC execution completed with non-zero exit code.

func NewRsyncCallFailedError

func NewRsyncCallFailedError(exitCode int, stdErr *bytes.Buffer) *RsyncCallFailedError

NewRsyncCallFailedError creates error object based on ExitCode from RSYNC. Use STDERR variable to extract more human readable error description.

func (*RsyncCallFailedError) Error

func (v *RsyncCallFailedError) Error() string

type RsyncProcessTerminatedError

type RsyncProcessTerminatedError struct {
}

RsyncProcessTerminatedError denote a situation with termination pending.

func (*RsyncProcessTerminatedError) Error

Source Files

  • abstract.go
  • common.go
  • errors.go
  • messagekeys.go
  • rsync.go
  • utils.go

Jump to

Keyboard shortcuts

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