private void HandleDownloadedAppList(SyncResetMode resetMode, [NotNull] byte[] appListData)
{
if (appListData.Length == 0) return;
AppList serverList;
try
{
serverList = AppList.LoadXmlZip(new MemoryStream(appListData), _cryptoKey);
}
#region Error handling
catch (ZipException ex)
{
// Wrap exception to add context information
if (ex.Message == "Invalid password") throw new InvalidDataException(Resources.SyncCryptoKeyInvalid);
throw new InvalidDataException(Resources.SyncServerDataDamaged, ex);
}
#endregion
Handler.CancellationToken.ThrowIfCancellationRequested();
try
{
MergeData(serverList, resetClient: (resetMode == SyncResetMode.Client));
}
catch (KeyNotFoundException ex)
{
// Wrap exception since only certain exception types are allowed
throw new InvalidDataException(ex.Message, ex);
}
finally
{
Finish();
}
Handler.CancellationToken.ThrowIfCancellationRequested();
}