clean

package
v0.0.0-...-18d5ea8 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Copyright © 2020 Xiaokang An <anxiaokang@hotmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2020 Xiaokang An <anxiaokang@hotmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright © 2020 Xiaokang An <anxiaokang@hotmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var ErrStopBySignal = errors.New("fired by stop scanner signal")

Functions

This section is empty.

Types

type CleanerPool

type CleanerPool struct {

	// have done
	Done chan bool
	// contains filtered or unexported fields
}

CleanerPool keeps exactly n cleaners to do clean tasks.

func NewCleanerPool

func NewCleanerPool(root string, poolSize, scannerQueueSize int) *CleanerPool

NewCleanerPool creates a Pool of cleaners to do the clean jobs.

func (*CleanerPool) Run

func (cp *CleanerPool) Run()

Run wakes exactly n goroutines to do the clean jobs, which n == poolSize.

func (*CleanerPool) SetDebug

func (cp *CleanerPool) SetDebug()

func (*CleanerPool) Stop

func (cp *CleanerPool) Stop()

type GitRepo

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

GitRepo represents a git repo on disk.

func NewGitRepo

func NewGitRepo(root string) *GitRepo

NewGitRepo creates a GitRepo.

func (*GitRepo) CanRemove

func (g *GitRepo) CanRemove() bool

CanRemove indicates whether the repo can be deleted.

func (*GitRepo) LastAccess

func (g *GitRepo) LastAccess() (time.Time, error)

func (*GitRepo) Remove

func (g *GitRepo) Remove() error

Remove deletes the git repo through two steps: (1) mark the git repo as a garbage; (2) delete the garbage on disk.

func (*GitRepo) Root

func (g *GitRepo) Root() string

Root returns the path of GitRepo.

func (*GitRepo) Size

func (g *GitRepo) Size() (int64, error)

Size compute the approximate size of this repo including all files in bytes.

type Scanner

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

Scanner represents a scanner scanning and finding git repos on the disk.

func NewScanner

func NewScanner(root string, queueSize int) *Scanner

NewScanner creates a scanner with a queueSize.

func (*Scanner) Scan

func (s *Scanner) Scan()

Scan scans the target directory and finds the git repos.

func (*Scanner) Stop

func (s *Scanner) Stop()

Stop stops the scanner.

Jump to

Keyboard shortcuts

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