Hello. I have the following question. I call the nextBatch() method on MusicItemCollection<Album> to get the next collection of artist albums. Here is my method:
func allAlbums2(artist: Artist) async throws -> [Album] {
var allAlbums: [Album] = [] artist.albums?.forEach { allAlbums.append($0) }
guard let albums = artist.albums else { return [] }
var albumsCollection = albums
while albumsCollection.hasNextBatch {
let response = try await albumsCollection.nextBatch()
if let response {
albumsCollection = response
var albums = [Album]()
albumsCollection.forEach({ albums.append($0)})
allAlbums.append(contentsOf: albums)
}
}
return allAlbums
}
The problem is as follows. Sometimes it happens that some albums not in nextBatch are not returned (I noticed one, I didn't check the others). This happens once every 50-100 requests. The number of batches is returned the same when the album is skipped. The same albums are returned in the batch where the album was missed. I have a question, do I have a problem with multi-threading or something else or is it a problem in the API. The file contains prints of the returned batches. One with a missing album, the other without a missing one. There are about 3000 lines in the file. I will be grateful for a hint or an answer. Thank you!
Here link to file: https://files.fm/u/nj4r5wgyg3