Documentation ¶
Index ¶
Constants ¶
const ( // DefaultTimeout is the default value for Mover.Timeout DefaultTimeout = 5 * time.Minute // DefaultMinFileAge is the default value for Mover.MinFileAge DefaultMinFileAge = 5 * time.Minute // DefaultMinDirAge is the default value for Mover.MinDirAge DefaultMinDirAge = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func DefaultErrorFunc ¶
DefaultErrorFunc is the default function for Mover.ErrorFunc, it logs to log.Printf and returns resume=true.
Types ¶
type MoveAbortedError ¶
MoveAbortedError is used with Mover.ErrorFunc, see Mover for more info. Mover is the *Mover that was aborted, and Err is the error that aborted the interation. Note that this intentionally does not Unwrap Err.
func (*MoveAbortedError) Error ¶
func (err *MoveAbortedError) Error() string
type Mover ¶
type Mover struct { SourceDir string DestDir string Timeout time.Duration // default is DefaultTimeout MinFileAge time.Duration // default is DefaultMinFileAge MinDirAge time.Duration // default is DefaultMinDirAge ErrorFunc func(*Mover, error) (resume bool) // default is DefaultErrorFunc // contains filtered or unexported fields }
Mover will lazily move files from SourceDir into DestDir. It will do this iteration each Timeout, only moving files with modification times older than MinFileAge, and only removing empty directories with times older than MinDirAge. ErrorFunc is called on any errors that occur during a move, true can be returned to resume moving, or false to abort. If ErrorFunc returns false, it aborts the rest of the move iteration, and it is called again with a *MoveAbortedError, in this case the return value controls whether Run will resume or return. Behavior is undefined if SourceDir refers to the same location as DestDir. Do not modify fields after calling Run.