mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
ListenBrainz: Fix loves import loading all existing loves
Fixes import if the user had more than 1000 loves already
This commit is contained in:
parent
01e7569051
commit
da6c920789
1 changed files with 12 additions and 7 deletions
|
@ -233,15 +233,18 @@ func (b *ListenBrainzApiBackend) ImportLoves(export models.LovesResult, importRe
|
||||||
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)
|
||||||
existingLoves := <-existingLovesChan
|
|
||||||
if existingLoves.Error != nil {
|
|
||||||
return importResult, existingLoves.Error
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Store MBIDs directly
|
// TODO: Store MBIDs directly
|
||||||
b.existingMBIDs = make(map[mbtypes.MBID]bool, len(existingLoves.Items))
|
b.existingMBIDs = make(map[mbtypes.MBID]bool, MaxItemsPerGet)
|
||||||
for _, love := range existingLoves.Items {
|
|
||||||
b.existingMBIDs[love.RecordingMBID] = true
|
for existingLoves := range existingLovesChan {
|
||||||
|
if existingLoves.Error != nil {
|
||||||
|
return importResult, existingLoves.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, love := range existingLoves.Items {
|
||||||
|
b.existingMBIDs[love.RecordingMBID] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +271,8 @@ func (b *ListenBrainzApiBackend) ImportLoves(export models.LovesResult, importRe
|
||||||
ok = err == nil && resp.Status == "ok"
|
ok = err == nil && resp.Status == "ok"
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg = err.Error()
|
errMsg = err.Error()
|
||||||
|
} else {
|
||||||
|
b.existingMBIDs[recordingMBID] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue