Skip to content

Commit

Permalink
Rebuild Cache checking, so it still works on an unconfigured umbraco …
Browse files Browse the repository at this point in the history
…site.
  • Loading branch information
Kevin Jump committed Sep 26, 2019
1 parent 1f4db0f commit 529b080
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
14 changes: 7 additions & 7 deletions uSync8.BackOffice/Cache/RebuildCacheComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ public class RebuildCacheComposer : ComponentComposer<RebuildCacheComponent> { }
public class RebuildCacheComponent : IComponent
{
private readonly IPublishedSnapshotService snapshotService;
private uSyncSettings settings;
private bool rebuildCacheOnCompleaton;

public RebuildCacheComponent(IPublishedSnapshotService snapshotService)
{
this.snapshotService = snapshotService;

this.settings = Current.Configs.uSync();

uSyncConfig.Reloaded += Config_Reloaded;
}

private void Config_Reloaded(uSyncSettings settings)
{
this.settings = Current.Configs.uSync();
rebuildCacheOnCompleaton = settings.RebuildCacheOnCompleation;
}

public void Initialize()
{
var config = Current.Configs.uSync();
if (config != null)
Config_Reloaded(config);

uSyncService.ImportComplete += ImportComplete;

}

private void ImportComplete(uSyncBulkEventArgs e)
{
if (settings.RebuildCacheOnCompleation &&
if (rebuildCacheOnCompleaton &&
e.Actions.Any(x => x.Change > uSync8.Core.ChangeType.NoChange))
{
// change happened. - rebuild
Expand Down
12 changes: 11 additions & 1 deletion uSync8.BackOffice/Configuration/ConfigExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ namespace uSync8.BackOffice.Configuration
public static class ConfigExtensions
{
public static uSyncSettings uSync(this Configs configs)
=> configs.GetConfig<uSyncConfig>().Settings;
{
try
{
return configs.GetConfig<uSyncConfig>().Settings;
}
catch
{
return null;
}
}

}
}
2 changes: 0 additions & 2 deletions uSync8.BackOffice/uSyncBackOfficeComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public void Compose(Composition composition)

composition.RegisterUnique<SyncHandlerFactory>();

composition.Configs.Add<uSyncConfig>(() => new uSyncConfig());

composition.RegisterUnique<uSyncService>();
}
}
Expand Down

0 comments on commit 529b080

Please sign in to comment.