mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2024-11-05 13:14:48 +01:00
1512db5b55
Co-authored-by: mariom <11mariom@gmail.com>
23 lines
544 B
Go
23 lines
544 B
Go
package metadata
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
type addedExtractor struct {
|
|
re *regexp.Regexp
|
|
}
|
|
|
|
func (e addedExtractor) Matches(line string) bool {
|
|
return e.re.MatchString(line)
|
|
}
|
|
func (e addedExtractor) Extract(metadata *BackupLogMetadata, line string) {
|
|
// Sample line: "Added to the repo: 0 B"
|
|
metadata.AddedSize = strings.TrimSpace(e.re.ReplaceAllString(line, "$2"))
|
|
}
|
|
|
|
func NewAddedExtractor() MetadatExtractor {
|
|
return addedExtractor{regexp.MustCompile(`(?i)^Added to the repo(sitory)?: ([\d\.]+ \w+)( \([\d\.]+[\w\s]+\))?`)}
|
|
}
|