forked from rosa/hakurei
internal/pkg: garbage collection
This destroys cache entries not referred to by user-specified artifacts and optionally their inputs. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -816,6 +816,28 @@ func (e *ChecksumMismatchError) Error() string {
|
||||
" instead of " + Encode(e.Want)
|
||||
}
|
||||
|
||||
// LinknamePrefixError describes a malformed linkname to a [Checksum].
|
||||
type LinknamePrefixError string
|
||||
|
||||
func (e LinknamePrefixError) Error() string {
|
||||
return "linkname " + strconv.Quote(string(e)) + " missing prefix"
|
||||
}
|
||||
|
||||
// readlinkChecksum reads a symbolic link to a dirChecksum entry and saves the
|
||||
// decoded [Checksum] to the value pointed to by buf. The checksumLinknamePrefix
|
||||
// is required.
|
||||
func readlinkChecksum(a *check.Absolute, buf *Checksum) error {
|
||||
linkname, err := os.Readlink(a.String())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(linkname, checksumLinknamePrefix) {
|
||||
return LinknamePrefixError(linkname)
|
||||
}
|
||||
return Decode(buf, linkname[len(checksumLinknamePrefix):])
|
||||
}
|
||||
|
||||
// ScrubError describes the outcome of a [Cache.Scrub] call where errors were
|
||||
// found and removed from the underlying storage of [Cache].
|
||||
type ScrubError struct {
|
||||
|
||||
Reference in New Issue
Block a user