reaper

package module
v0.0.0-...-71710c0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2017 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Reaper

A tool written exclusively in Go to rid a file system of stale files that may no longer be needed. It is inspired by tmpreaper and fits the use case of wanting a tool but not wanting a massive build toolchain to be present to use it — e.g., Xcode on Mac OS for Homebrew.

Installation

Initial compilation and installation require the Go toolchain. It is an easy and fast download. Thereafter the binary may be distributed as a static linked archive.

go get github.com/matttproud/reaper/cmd/reaper
cp ${GOPATH}/src/github.com/matttproud/reaper/cmd/reaper/reaper.1 \
    -t ${HOME}/.local/share/man/man1

Useful Features and Characteristics

  • Portable implementation

  • 1/4 the lines of code of tmpreaper

  • The core has unit and integration tests

  • It is easy to extend; the core exists as a regular Go package (library) for other tools to build upon

License

As described in LICENSE, it is Apache License version 2.

Warranty

See WARRANTY.

Build Status

GoDoc

Documentation

Overview

Package reaper provides the business logic for safely identifying stale files for deletion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	os.FileInfo
	// Path is the file's full-path relative to the search root.
	Path string
}

Entry models a file eligible for deletion.

type Option

type Option func(*Reaper)

Option defines a runtime parameter for the reaper.

func ExpungeAfter

func ExpungeAfter(d time.Duration) Option

ExpungeAfter identifies files for deletion whose access time surpasses d.

func ExpungeIrregular

func ExpungeIrregular() Option

ExpungeIrregular allows irregular files to be deleted --- i.e., non-regular files and directories.

func Force

func Force() Option

Force instructs the reaper to ignore permissions and report candidates eligible by age.

func Protect

func Protect(globs ...string) Option

Protect applies a blacklist pattern the Reaper, meaning no files or directories that match it will be visited nor marked as eligible for deletion.

type Reaper

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

Reaper scans the the filesystem for stale files that may be eligible for safe deletion.

func New

func New(root string, opts ...Option) (*Reaper, error)

New creates a new Reaper for scanning the root. The root directory must exist.

func (*Reaper) Err

func (r *Reaper) Err() error

Err reports whether the scanner incurred an error. It is only set after the Scan method returns false.

func (*Reaper) File

func (r *Reaper) File() *Entry

File returns this scan iteration's findings.

func (*Reaper) Scan

func (r *Reaper) Scan() bool

Scan runs a single cycle of the scanning loop. If it returns false, there are no more files to report.

func (*Reaper) Stop

func (r *Reaper) Stop()

Stop instructs the scanner to finish scanning if it hasn't already. It should always be called.

Directories

Path Synopsis
cmd
reaper command
Binary reaper cleans files that have not been accessed past a provided expiry.
Binary reaper cleans files that have not been accessed past a provided expiry.
Package flag provides extra flag.Value implementations.
Package flag provides extra flag.Value implementations.

Jump to

Keyboard shortcuts

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