From 89cb450bb2c82e7f0e9627d1aec1873db6b705e0 Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Wed, 18 Oct 2017 16:20:24 +0300 Subject: [PATCH] Added extra null checks for sync data and sharing public folder --- .../Features/SyncState/FeatureSyncState.cs | 37 ++++++++++--------- .../ZPush/ContactStringReplacer.cs | 3 ++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs index 1c0921b..4dddaf8 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SyncState/FeatureSyncState.cs @@ -356,27 +356,30 @@ namespace Acacia.Features.SyncState HashSet syncingNow = new HashSet(); // Check all syncing data - foreach (KeyValuePair contentEntry in details.Content) + if (details.Content != null) { - DeviceDetails.ContentData content = contentEntry.Value; - content.Key = contentEntry.Key; - - if (content.IsSyncing) + foreach (KeyValuePair contentEntry in details.Content) { - // If the current session is not syncing, this is a restart. Clear stat - if (!IsSyncing) + DeviceDetails.ContentData content = contentEntry.Value; + content.Key = contentEntry.Key; + + if (content.IsSyncing) { - _syncContent.Clear(); - debug.AppendLine("Starting new SyncSession"); + // If the current session is not syncing, this is a restart. Clear stat + if (!IsSyncing) + { + _syncContent.Clear(); + debug.AppendLine("Starting new SyncSession"); + } + + // Add to the syncing content + IsSyncing = true; + _syncContent[content.Key] = content; + syncingNow.Add(content.Key); + + debug.AppendLine(string.Format("\tFolder: {0} \tSync: {1} \tStatus: {2} / {3}", + content.Key, content.IsSyncing, content.Sync.done, content.Sync.total)); } - - // Add to the syncing content - IsSyncing = true; - _syncContent[content.Key] = content; - syncingNow.Add(content.Key); - - debug.AppendLine(string.Format("\tFolder: {0} \tSync: {1} \tStatus: {2} / {3}", - content.Key, content.IsSyncing, content.Sync.done, content.Sync.total)); } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ContactStringReplacer.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ContactStringReplacer.cs index f0d0532..5436732 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ContactStringReplacer.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/ContactStringReplacer.cs @@ -81,6 +81,9 @@ namespace Acacia.ZPush if (result != null && result != contact) result.Dispose(); + if (contact == null) + return null; + return new ContactStringReplacer(contact); }