add upgrade logic to cleanup assets which were moved to a new location in 6.2.0
This commit is contained in:
@ -7,11 +7,15 @@ using Oqtane.Infrastructure.SiteTemplates;
|
|||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Oqtane.Shared;
|
using Oqtane.Shared;
|
||||||
|
using Oqtane.UI;
|
||||||
|
using Org.BouncyCastle.Pqc.Crypto.Lms;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Oqtane.Infrastructure
|
namespace Oqtane.Infrastructure
|
||||||
{
|
{
|
||||||
@ -90,6 +94,9 @@ namespace Oqtane.Infrastructure
|
|||||||
case "6.2.0":
|
case "6.2.0":
|
||||||
Upgrade_6_2_0(tenant, scope);
|
Upgrade_6_2_0(tenant, scope);
|
||||||
break;
|
break;
|
||||||
|
case "6.2.1":
|
||||||
|
Upgrade_6_2_1(tenant, scope);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -598,6 +605,25 @@ namespace Oqtane.Infrastructure
|
|||||||
AddPagesToSites(scope, tenant, pageTemplates);
|
AddPagesToSites(scope, tenant, pageTemplates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Upgrade_6_2_1(Tenant tenant, IServiceScope scope)
|
||||||
|
{
|
||||||
|
// remove text editor files moved to new location
|
||||||
|
string[] files = {
|
||||||
|
"js/quill.min.js.map",
|
||||||
|
"js/quill1.3.7.min.js",
|
||||||
|
"js/quill.min.js",
|
||||||
|
"js/quill-blot-formatter.min.js",
|
||||||
|
"js/quill-interop.js",
|
||||||
|
"css/quill/quill1.3.7.bubble.css",
|
||||||
|
"css/quill/quill.bubble.css",
|
||||||
|
"css/quill/quill1.3.7.snow.css",
|
||||||
|
"css/quill/quill.snow.css",
|
||||||
|
"oqtane-black.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
RemoveFiles(tenant, files, "6.2.1");
|
||||||
|
}
|
||||||
|
|
||||||
private void AddPagesToSites(IServiceScope scope, Tenant tenant, List<PageTemplate> pageTemplates)
|
private void AddPagesToSites(IServiceScope scope, Tenant tenant, List<PageTemplate> pageTemplates)
|
||||||
{
|
{
|
||||||
var tenants = scope.ServiceProvider.GetRequiredService<ITenantManager>();
|
var tenants = scope.ServiceProvider.GetRequiredService<ITenantManager>();
|
||||||
@ -618,8 +644,8 @@ namespace Oqtane.Infrastructure
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var binFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
var bin = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||||
var filepath = Path.Combine(binFolder, assembly);
|
var filepath = Path.Combine(bin, assembly);
|
||||||
if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath);
|
if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -630,5 +656,26 @@ namespace Oqtane.Infrastructure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RemoveFiles(Tenant tenant, string[] files, string version)
|
||||||
|
{
|
||||||
|
if (tenant.Name == TenantNames.Master)
|
||||||
|
{
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var wwwroot = _environment.WebRootPath;
|
||||||
|
var filepath = Path.Combine(wwwroot, file);
|
||||||
|
if (System.IO.File.Exists(filepath)) System.IO.File.Delete(filepath);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// error deleting file
|
||||||
|
_filelogger.LogError(Utilities.LogMessage(this, $"Oqtane Error: {version} Upgrade Error Removing {file} - {ex}"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user