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,6 +291,8 @@ namespace Acacia.Features.GAB
BeginProcessing(); BeginProcessing();
// Delete any contacts folders in the local store // Delete any contacts folders in the local store
if (DeleteExistingFolder)
{
using (ZPushLocalStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance)) using (ZPushLocalStore store = ZPushLocalStore.GetInstance(ThisAddIn.Instance))
{ {
if (store != null) if (store != null)
@ -292,6 +321,7 @@ namespace Acacia.Features.GAB
} }
} }
} }
}
// Do the resync // Do the resync
foreach (GABHandler gab in _gabsByDomainName.Values) foreach (GABHandler gab in _gabsByDomainName.Values)
@ -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