Replaced ImportResult.ImportErrors with ImportResult.ImportLog

This commit is contained in:
Philipp Wolfer 2024-01-15 08:00:17 +01:00
parent 91f9b62db3
commit 8a2ddb7772
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
5 changed files with 55 additions and 13 deletions

View file

@ -164,11 +164,24 @@ type ListensResult ExportResult[ListensList]
type LovesResult ExportResult[LovesList]
type LogEntryType string
const (
Info LogEntryType = "Info"
Warning LogEntryType = "Warning"
Error LogEntryType = "Error"
)
type LogEntry struct {
Type LogEntryType
Message string
}
type ImportResult struct {
TotalCount int
ImportCount int
LastTimestamp time.Time
ImportErrors []string
ImportLog []LogEntry
// Error is only set if an unrecoverable import error occurred
Error error
@ -185,7 +198,14 @@ func (i *ImportResult) Update(from ImportResult) {
i.TotalCount = from.TotalCount
i.ImportCount = from.ImportCount
i.UpdateTimestamp(from.LastTimestamp)
i.ImportErrors = append(i.ImportErrors, from.ImportErrors...)
i.ImportLog = append(i.ImportLog, from.ImportLog...)
}
func (i *ImportResult) Log(t LogEntryType, msg string) {
i.ImportLog = append(i.ImportLog, LogEntry{
Type: t,
Message: msg,
})
}
type Progress struct {