srm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: BSD-3-Clause-Clear Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Auto clean size limit for all files and directories
	AutocleanSizeUpper = datasize.MB * 15 // 15Mbs
	AutocleanSizeLower = datasize.B * 50  // 50 bytes
)

Functions

func SafeRMF

func SafeRMF(path string) error

SafeRMF is a wrapper for os.RemoveAll, but **would** apply some safety checks before removing the file/dir.

Types

type Entry

type Entry struct {
	Path  string            `json:"path"`
	Index int               `json:"index"`
	IsDir bool              `json:"is_dir"`
	Size  datasize.ByteSize `json:"size"`
	Date  time.Time         `json:"time"`
}

type Manager

type Manager struct {
	Data *SrmData
	// contains filtered or unexported fields
}

func New

func New(options *Options) (*Manager, error)

func (*Manager) CleanCache

func (m *Manager) CleanCache(all, dryRun bool) error

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) ListAllCache

func (m *Manager) ListAllCache(bySize, byTime bool) error

func (*Manager) ListRecentCache

func (m *Manager) ListRecentCache() error

func (*Manager) RM

func (m *Manager) RM(path string) error

func (*Manager) Recover

func (m *Manager) Recover(index int) error

Recover recovers a entry to the current working directory. index should 1 = newest, 10 = 10 before the newest.

type Options

type Options struct {
	Force          bool
	Recursive      bool
	RemoveEmptyDir bool // TODO: not used yet
}

Options is the remove options for the file

type SrmData

type SrmData struct {
	Entries        []*Entry `json:"entry"`
	LastTrashIndex int      `json:"last_index"`
}

func (*SrmData) Remove

func (d *SrmData) Remove(index int) error

Remove removes the entry from cache dir TODO: this should only be used for index 0, this function will be replaced later.

Jump to

Keyboard shortcuts

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