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