2021-10-26 13:57:40 +00:00
|
|
|
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"
|
2023-01-18 21:39:12 +00:00
|
|
|
metadata.AddedSize = strings.TrimSpace(e.re.ReplaceAllString(line, "$2"))
|
2021-10-26 13:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewAddedExtractor() MetadatExtractor {
|
2023-01-18 21:39:12 +00:00
|
|
|
return addedExtractor{regexp.MustCompile(`(?i)^Added to the repo(sitory)?: ([\d\.]+ \w+)( \([\d\.]+[\w\s]+\))?`)}
|
2021-10-26 13:57:40 +00:00
|
|
|
}
|