ListenBrainz: Fix love import progress

Exporting existing loves must not mark the progress as completed.
This commit is contained in:
Philipp Wolfer 2025-04-27 16:57:30 +02:00
parent da6c920789
commit 2d66d41873
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B

View file

@ -188,6 +188,10 @@ func (b *ListenBrainzApiBackend) ImportListens(export models.ListensResult, impo
} }
func (b *ListenBrainzApiBackend) ExportLoves(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.Progress) { func (b *ListenBrainzApiBackend) ExportLoves(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.Progress) {
b.exportLoves(oldestTimestamp, results, progress, false)
}
func (b *ListenBrainzApiBackend) exportLoves(oldestTimestamp time.Time, results chan models.LovesResult, progress chan models.Progress, completeProgress bool) {
offset := 0 offset := 0
defer close(results) defer close(results)
loves := make(models.LovesList, 0, 2*MaxItemsPerGet) loves := make(models.LovesList, 0, 2*MaxItemsPerGet)
@ -225,14 +229,16 @@ out:
} }
sort.Sort(loves) sort.Sort(loves)
if completeProgress {
progress <- p.Complete() progress <- p.Complete()
}
results <- models.LovesResult{Items: loves} results <- models.LovesResult{Items: loves}
} }
func (b *ListenBrainzApiBackend) ImportLoves(export models.LovesResult, importResult models.ImportResult, progress chan models.Progress) (models.ImportResult, error) { func (b *ListenBrainzApiBackend) ImportLoves(export models.LovesResult, importResult models.ImportResult, progress chan models.Progress) (models.ImportResult, error) {
if len(b.existingMBIDs) == 0 { if len(b.existingMBIDs) == 0 {
existingLovesChan := make(chan models.LovesResult) existingLovesChan := make(chan models.LovesResult)
go b.ExportLoves(time.Unix(0, 0), existingLovesChan, progress) go b.exportLoves(time.Unix(0, 0), existingLovesChan, progress, false)
// TODO: Store MBIDs directly // TODO: Store MBIDs directly
b.existingMBIDs = make(map[mbtypes.MBID]bool, MaxItemsPerGet) b.existingMBIDs = make(map[mbtypes.MBID]bool, MaxItemsPerGet)