diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs index e16abf6..a01c5f4 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/FeatureSharedFolders.cs @@ -88,11 +88,12 @@ namespace Acacia.Features.SharedFolders private void AdditionalFolders_Sync(ZPushConnection connection) { - Logger.Instance.Debug(this, "Starting sync for account {0}", connection.Account); - using (SharedFoldersAPI api = new SharedFoldersAPI(connection)) + using (SharedFoldersManager manager = Manage(connection.Account)) { + Logger.Instance.Debug(this, "Starting sync for account {0}", connection.Account); + // Fetch the current shares - ICollection shares = api.GetCurrentShares(); + ICollection shares = manager.GetCurrentShares(null); Logger.Instance.Trace(this, "AdditionalFolders_Sync: {0}", shares.Count); // Convert to dictionary diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/RemindersQuery.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/RemindersQuery.cs index 9b15b0f..52504bb 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/RemindersQuery.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/SharedFolders/RemindersQuery.cs @@ -98,6 +98,8 @@ namespace Acacia.Features.SharedFolders { Logger.Instance.Trace(this, "Setting reminders for folder {0}: {1}", wantReminders, folderId); string prefix = MakeFolderPrefix(folderId); + if (prefix == null) + return; // Find existing for (int i = 0; i < _queryCustom.Operands.Count;) @@ -131,7 +133,11 @@ namespace Acacia.Features.SharedFolders // Collect the valid prefixes HashSet prefixes = new HashSet(); foreach (SyncId id in wanted) - prefixes.Add(MakeFolderPrefix(id)); + { + string prefix = MakeFolderPrefix(id); + if (prefix != null) + prefixes.Add(prefix); + } // Remove all operands for which we do not want the prefix for (int i = 0; i < _queryCustom.Operands.Count;) @@ -155,6 +161,10 @@ namespace Acacia.Features.SharedFolders private string MakeFolderPrefix(SyncId folderId) { + // Sanity check. The check for shared folders also excludes any weird ids; e.g. if permissions are wrong, + // this will not be a sync id, but a backend id. + if (folderId == null || !folderId.IsShared) + return null; return folderId.ToString() + ":"; } } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/API/SharedFolders/SharedFolder.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/API/SharedFolders/SharedFolder.cs index 248424a..2d996d8 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/API/SharedFolders/SharedFolder.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/ZPush/API/SharedFolders/SharedFolder.cs @@ -20,7 +20,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static Acacia.ZPush.API.SharedFolders.SharedFoldersAPI; namespace Acacia.ZPush.API.SharedFolders {