Added extra GAB debug options

This commit is contained in:
Patrick Simpson 2017-02-08 16:41:24 +01:00
parent b4d84ef303
commit af9abbe196
2 changed files with 58 additions and 18 deletions

View File

@ -173,6 +173,33 @@ namespace Acacia.Features.GAB
} }
private static readonly BoolOption OPTION_CHECK_UNUSED = new BoolOption("CheckUnused", true); private static readonly BoolOption OPTION_CHECK_UNUSED = new BoolOption("CheckUnused", true);
[AcaciaOption("If disabled, existing contacts are not cleared before new contacts are created. " +
"This should only be disabled for debug purposes.")]
public bool ClearContacts
{
get { return GetOption(OPTION_CLEAR_CONTACTS); }
set { SetOption(OPTION_CLEAR_CONTACTS, value); }
}
private static readonly BoolOption OPTION_CLEAR_CONTACTS = new BoolOption("ClearContacts", true);
[AcaciaOption("If disabled, existing contact folders are not deleted before new contacts are created. " +
"This should only be disabled for debug purposes.")]
public bool DeleteExistingFolder
{
get { return GetOption(OPTION_DELETE_EXISTING_FOLDER); }
set { SetOption(OPTION_DELETE_EXISTING_FOLDER, value); }
}
private static readonly BoolOption OPTION_DELETE_EXISTING_FOLDER = new BoolOption("DeleteExistingFolder", true);
[AcaciaOption("If disabled, deleted items are not removed from the waste basket. " +
"This should only be disabled for debug purposes.")]
public bool EmptyDeletedItems
{
get { return GetOption(OPTION_EMPTY_DELETED_ITEMS); }
set { SetOption(OPTION_EMPTY_DELETED_ITEMS, value); }
}
private static readonly BoolOption OPTION_EMPTY_DELETED_ITEMS = new BoolOption("EmptyDeletedItems", true);
#endregion #endregion
#region Modification suppression #region Modification suppression
@ -264,28 +291,31 @@ namespace Acacia.Features.GAB
BeginProcessing(); BeginProcessing();
// Delete any contacts folders in the local store // Delete any contacts folders in the local store
using (ZPushLocalStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance)) if (DeleteExistingFolder)
{ {
if (store != null) using (ZPushLocalStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance))
{ {
using (IFolder root = store.RootFolder) if (store != null)
{ {
foreach (IFolder folder in root.GetSubFolders<IFolder>()) using (IFolder root = store.RootFolder)
{ {
// TODO: let enumerator handle this foreach (IFolder folder in root.GetSubFolders<IFolder>())
using (folder)
{ {
try // TODO: let enumerator handle this
using (folder)
{ {
if (IsGABContactsFolder(folder)) try
{ {
Logger.Instance.Debug(this, "FullResync: Deleting contacts folder: {0}", folder.Name); if (IsGABContactsFolder(folder))
folder.Delete(); {
Logger.Instance.Debug(this, "FullResync: Deleting contacts folder: {0}", folder.Name);
folder.Delete();
}
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "FullResync: Exception deleting contacts folder: {0}", e);
} }
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "FullResync: Exception deleting contacts folder: {0}", e);
} }
} }
} }
@ -501,7 +531,7 @@ namespace Acacia.Features.GAB
} }
if (deletedSomething) if (deletedSomething)
EmptyDeletedItems(); DoEmptyDeletedItems();
} }
private void CheckGABRemoved() private void CheckGABRemoved()
@ -536,7 +566,7 @@ namespace Acacia.Features.GAB
} }
} }
EmptyDeletedItems(); DoEmptyDeletedItems();
} }
} }
@ -607,7 +637,7 @@ namespace Acacia.Features.GAB
try try
{ {
gab.Process(item); gab.Process(item);
EmptyDeletedItems(); DoEmptyDeletedItems();
} }
finally finally
{ {
@ -616,8 +646,11 @@ namespace Acacia.Features.GAB
} }
} }
private void EmptyDeletedItems() private void DoEmptyDeletedItems()
{ {
if (!EmptyDeletedItems)
return;
if (_store != null) if (_store != null)
_store.EmptyDeletedItems(); _store.EmptyDeletedItems();
} }

View File

@ -136,6 +136,13 @@ namespace Acacia.Features.GAB
private void ClearContacts() private void ClearContacts()
{ {
if (!_feature.ClearContacts)
{
using (IStorageItem item = GetIndexItem())
item?.Delete();
return;
}
if (Contacts != null) if (Contacts != null)
{ {
try try