diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs index 9600bbee00..4c83904e9f 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs @@ -1,9 +1,5 @@ using Umbraco.Cms.Core; using Umbraco.Cms.Core.Configuration; -using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_0_0; -using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_2_0; -using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_10_5_0; -using Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_12_0_0; namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade; @@ -76,6 +72,7 @@ public class UmbracoPlan : MigrationPlan To("{BB3889ED-E2DE-49F2-8F71-5FD8616A2661}"); // To 12.0.0 - To("{888A0D5D-51E4-4C7E-AA0A-01306523C7FB}"); + To("{888A0D5D-51E4-4C7E-AA0A-01306523C7FB}"); + To("{539F2F83-FBA7-4C48-81A3-75081A56BB9D}"); } } diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_0_0/ResetCache.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_0_0/ResetCache.cs new file mode 100644 index 0000000000..ce105bf6b8 --- /dev/null +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_12_0_0/ResetCache.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Hosting; +using Umbraco.Cms.Core; +using Umbraco.Cms.Core.Extensions; + +namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_12_0_0; + +public class ResetCache : MigrationBase +{ + private readonly IHostEnvironment _hostEnvironment; + + public ResetCache(IMigrationContext context, IHostEnvironment hostEnvironment) + : base(context) => _hostEnvironment = hostEnvironment; + + protected override void Migrate() + { + RebuildCache = true; + var distCacheFolderAbsolutePath = _hostEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempData + "/DistCache"); + var nuCacheFolderAbsolutePath = _hostEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempData + "/NuCache"); + DeleteAllFilesInFolder(distCacheFolderAbsolutePath); + DeleteAllFilesInFolder(nuCacheFolderAbsolutePath); + } + + private void DeleteAllFilesInFolder(string path) + { + var directoryInfo = new DirectoryInfo(path); + + foreach (FileInfo file in directoryInfo.GetFiles()) + { + file.Delete(); + } + } +}