Documentation
¶
Index ¶
- Constants
- func CalcChecksum(file string) (string, error)
- func GetCachedChecksum(file string) (string, error)
- func GetFiles(path string) []string
- type CheckSumCache
- func (c *CheckSumCache) Clean() error
- func (c *CheckSumCache) IsCached(file string) bool
- func (c *CheckSumCache) IsCachedMatched(file string, sha256 string) bool
- func (c *CheckSumCache) IsCachedMatchingFile(file string) bool
- func (c *CheckSumCache) Keep(file string)
- func (c *CheckSumCache) Update(file string) (checksum string, err error)
- type CheckSumItem
Constants ¶
const (
// CheckSumFileName is the checksum file name (base with no directories)
DefaultCheckSumFileName = "checksum.txt"
)
Variables ¶
This section is empty.
Functions ¶
func CalcChecksum ¶
CalcChecksum works out the checksum string
func GetCachedChecksum ¶
GetCachedChecksum will return previously calculated checksum
Types ¶
type CheckSumCache ¶ added in v0.2.0
type CheckSumCache struct { AddedItems []CheckSumItem CheckSumsByFilePath map[string]CheckSumItem CheckSumFile string Dir string }
CheckSumCache defines data for a hash cache
func NewFromCheckSumsFile ¶ added in v0.2.0
func NewFromCheckSumsFile(file string, errIfMissing bool) (c *CheckSumCache, err error)
NewCacheFromCheckSumsFile creates a cache interface from a specific checksum file
func NewFromDir ¶ added in v0.2.0
func NewFromDir(dir string, errIfMissing bool) (c *CheckSumCache, err error)
NewCacheFromDir instanciates a cache using the default cache file name given a directory. Optionally error if checksum file is missing
func NewFromExistingFile ¶ added in v0.2.0
func NewFromExistingFile( file string, create bool) (c *CheckSumCache, err error)
NewFromExistingFile creates an existing cache (relative from the file name) optionally will create the cache item...
func (*CheckSumCache) Clean ¶ added in v0.3.6
func (c *CheckSumCache) Clean() error
Clean will remove any old entries (not added using Update method)
func (*CheckSumCache) IsCached ¶ added in v0.2.0
func (c *CheckSumCache) IsCached(file string) bool
IsCached will check if a file is present on disk and in the checksum file
func (*CheckSumCache) IsCachedMatched ¶ added in v0.2.0
func (c *CheckSumCache) IsCachedMatched(file string, sha256 string) bool
IsCachedMatched will verify if a file is in Cache AND matching expected sha256
func (*CheckSumCache) IsCachedMatchingFile ¶ added in v0.3.10
func (c *CheckSumCache) IsCachedMatchingFile(file string) bool
IsCachedMatchingFile will check if the cache checksum matches calculated
func (*CheckSumCache) Keep ¶ added in v0.3.8
func (c *CheckSumCache) Keep(file string)
Keep will mark a file (and checksum) so it won't be cleaned with .Clean
type CheckSumItem ¶ added in v0.2.0
type CheckSumItem struct { // CheckSum is the sha256sum initialy calculated CheckSum string // CheckSumCached indicates if the checksum has been calculated or cached CheckSumCached bool // FilePath is the full path to a file given a start directory FilePath string // FileName is a relative file name only FileName string }
CheckSumItem represents a single file as present in cache (checksum file)