I have an issue where I request an Asset Pager from a collection, loop through each page, and then foreach through each object in those pages, and sometimes there are duplicate assets showing up in the pages. The exact same asset identifier shows up twice. It doesn't always happen, and since it can take a minute or two between request for a subsequent page (due to processing of the assets in the current page), I'm wondering if something corrupts the asset pager, and what that could be? The collection doesn't change.
An example of the code below. The "ReportError" should never happen in my opinion, but it occasionally does (and randomly, never the same way twice). Am I making an improper assumption that pager for a static collection isn't mutable by Mediabin? Since these collections can be large, I don't want to do a "GetAllObjects" request... but is that my only option?
private bool ProcessCollection(MBObject thisCollection)
{
string pager = serverRef.CreateAssetPager(thisCollection.Identifier, MBObjectType.Collection);
MBObjectPage page = serverRef.GetPage(pager, 0);
int totalPages = page.TotalPages;
int currentPageIndex = 1;
NumAssets = page.TotalObjects;
int numProcessed = 0;
List<string> assetList = new List<string>();
UpdateStats();
while (currentPageIndex <= totalPages && !cancelled)
{
page = serverRef.GetPage(pager, currentPageIndex);
foreach (MBObject asset in page.Objects)
{
if (!assetList.Contains(asset.Identifier))
{
assetList.Add(asset.Identifier);
}
else
{
ReportError(asset.Name, "Already added to Process Queue");
continue;
}
numProcessed++;
_asyncProcessAsset(asset);
}
currentPageIndex++;
}
return true;
}