From 7211f94f08807f9204598a969c32b83086b87c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Fri, 16 Aug 2024 00:40:10 +0200 Subject: [PATCH] Try - catch for outlook profile sync. --- .../Synchronizers/OutlookSynchronizer.cs | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/Wino.Core/Synchronizers/OutlookSynchronizer.cs b/Wino.Core/Synchronizers/OutlookSynchronizer.cs index 89496165..7080e9c7 100644 --- a/Wino.Core/Synchronizers/OutlookSynchronizer.cs +++ b/Wino.Core/Synchronizers/OutlookSynchronizer.cs @@ -513,28 +513,35 @@ namespace Wino.Core.Synchronizers protected override async Task SynchronizeProfileInformationAsync() { - // Outlook profile info synchronizes Sender Name and Profile Picture. - string senderName = Account.SenderName, base64ProfilePicture = Account.ProfilePictureBase64; - - var profilePictureData = await GetUserProfilePictureAsync().ConfigureAwait(false); - senderName = await GetSenderNameAsync().ConfigureAwait(false); - - bool shouldUpdateAccountProfile = (!string.IsNullOrEmpty(senderName) && Account.SenderName != senderName) - || (!string.IsNullOrEmpty(profilePictureData) && Account.ProfilePictureBase64 != base64ProfilePicture); - - if (!string.IsNullOrEmpty(profilePictureData) && Account.ProfilePictureBase64 != profilePictureData) + try { - Account.ProfilePictureBase64 = profilePictureData; + // Outlook profile info synchronizes Sender Name and Profile Picture. + string senderName = Account.SenderName, base64ProfilePicture = Account.ProfilePictureBase64; + + var profilePictureData = await GetUserProfilePictureAsync().ConfigureAwait(false); + senderName = await GetSenderNameAsync().ConfigureAwait(false); + + bool shouldUpdateAccountProfile = (!string.IsNullOrEmpty(senderName) && Account.SenderName != senderName) + || (!string.IsNullOrEmpty(profilePictureData) && Account.ProfilePictureBase64 != base64ProfilePicture); + + if (!string.IsNullOrEmpty(profilePictureData) && Account.ProfilePictureBase64 != profilePictureData) + { + Account.ProfilePictureBase64 = profilePictureData; + } + + if (!string.IsNullOrEmpty(senderName) && Account.SenderName != senderName) + { + Account.SenderName = senderName; + } + + if (shouldUpdateAccountProfile) + { + await _outlookChangeProcessor.UpdateAccountAsync(Account).ConfigureAwait(false); + } } - - if (!string.IsNullOrEmpty(senderName) && Account.SenderName != senderName) + catch (Exception ex) { - Account.SenderName = senderName; - } - - if (shouldUpdateAccountProfile) - { - await _outlookChangeProcessor.UpdateAccountAsync(Account).ConfigureAwait(false); + Log.Error(ex, "Failed to synchronize profile information for {Name}", Account.Name); } }