-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
COLI-1199: Combinator: Clear cache for a fresh deployment
- Loading branch information
Showing
6 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: Validate Pull Request | ||
|
||
on: | ||
push: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
validate-pull-request: | ||
uses: Lombiq/GitHub-Actions/.github/workflows/validate-pull-request.yml@dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Piedone.Combinator.Constants | ||
{ | ||
public static class FileNames | ||
{ | ||
public const string ClearCache = "_" + nameof(ClearCache) + ".txt"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Piedone.Combinator.Constants | ||
{ | ||
public static class FolderNames | ||
{ | ||
public const string PiedoneModules = "_" + nameof(PiedoneModules); | ||
public const string Combinator = nameof(Combinator); | ||
public const string Sites = nameof(Sites); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Orchard.Environment; | ||
using Orchard.Environment.Configuration; | ||
using Orchard.Environment.Extensions; | ||
using Orchard.FileSystems.AppData; | ||
using Piedone.Combinator.Constants; | ||
using Piedone.Combinator.Services; | ||
|
||
namespace Piedone.Combinator.EventHandlers | ||
{ | ||
[OrchardFeature("Piedone.Combinator")] | ||
public class CombinatorCacheClearingShellEventHandler : IOrchardShellEvents | ||
{ | ||
private readonly ICacheFileService _cacheFileService; | ||
private readonly IAppDataFolder _appDataFolder; | ||
private readonly ShellSettings _shellSettings; | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether emptying Combinator cache is disabled, primarily through HostComponents.config. | ||
/// </summary> | ||
public bool IsDisabled { get; set; } = true; | ||
|
||
public CombinatorCacheClearingShellEventHandler( | ||
ICacheFileService cacheFileService, | ||
IAppDataFolder appDataFolder, | ||
ShellSettings shellSettings) | ||
{ | ||
_cacheFileService = cacheFileService; | ||
_appDataFolder = appDataFolder; | ||
_shellSettings = shellSettings; | ||
} | ||
|
||
public void Activated() | ||
{ | ||
if (IsDisabled) return; | ||
|
||
var pathToClearCacheFile = _appDataFolder.Combine( | ||
FolderNames.Sites, _shellSettings.Name, FolderNames.PiedoneModules, FolderNames.Combinator, FileNames.ClearCache); | ||
|
||
if (!_appDataFolder.FileExists(pathToClearCacheFile)) return; | ||
|
||
_cacheFileService.Empty(); | ||
|
||
_appDataFolder.DeleteFile(pathToClearCacheFile); | ||
} | ||
|
||
public void Terminating() | ||
{ | ||
// Terminating event does not need to be implemented. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters