in code/KustoCopyConsole/Entity/InMemory/BlockCache.cs [47:87]
public BlockCache CleanOnRestart()
{
var newUrls = UrlMap.Values.AsEnumerable();
var newExtents = ExtentMap.Values.AsEnumerable();
// A block was in the middle of exporting
newUrls = RowItem.State == BlockState.Exporting
? Array.Empty<UrlCache>()
: UrlMap.Values;
// A block was in the middle of being ingested
newExtents = RowItem.State == BlockState.Queued
? Array.Empty<ExtentCache>()
: ExtentMap.Values;
// Bring back url to exported
if (RowItem.State == BlockState.Exported)
{
newUrls = newUrls
.Select(u =>
{
if (u.RowItem.State == UrlState.Queued)
{
var newUrl = u.RowItem.ChangeState(UrlState.Exported);
newUrl.SerializedQueuedResult = string.Empty;
return new UrlCache(newUrl);
}
else
{
return u;
}
});
}
return new BlockCache(
RowItem,
newUrls.ToImmutableDictionary(u => u.RowItem.Url),
newExtents.ToImmutableDictionary(e => e.RowItem.ExtentId));
}