mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
ListenBrainz: Fix love import progress
Exporting existing loves must not mark the progress as completed.
This commit is contained in:
parent
da6c920789
commit
2d66d41873
1 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||||
progress <- p.Complete()
|
if completeProgress {
|
||||||
|
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue