diff --git a/Oqtane.Server/Controllers/InstallationController.cs b/Oqtane.Server/Controllers/InstallationController.cs index 1e4c87167..13334c5a7 100644 --- a/Oqtane.Server/Controllers/InstallationController.cs +++ b/Oqtane.Server/Controllers/InstallationController.cs @@ -30,11 +30,12 @@ public class InstallationController : Controller private readonly IMemoryCache _cache; private readonly IHttpContextAccessor _accessor; private readonly IAliasRepository _aliases; + private readonly ISiteRepository _sites; private readonly ILogger _filelogger; private readonly ITenantManager _tenantManager; private readonly IServerStateManager _serverState; - public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases, ILogger filelogger, ITenantManager tenantManager, IServerStateManager serverState) + public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases, ISiteRepository sites, ILogger filelogger, ITenantManager tenantManager, IServerStateManager serverState) { _configManager = configManager; _installationManager = installationManager; @@ -43,6 +44,7 @@ public InstallationController(IConfigManager configManager, IInstallationManager _cache = cache; _accessor = accessor; _aliases = aliases; + _sites = sites; _filelogger = filelogger; _tenantManager = tenantManager; _serverState = serverState; @@ -105,14 +107,32 @@ public void Restart() [HttpGet("list")] public List List() { - return GetAssemblyList().Select(item => item.HashedName).ToList(); + var alias = _tenantManager.GetAlias(); + var site = _sites.GetSite(alias.SiteId); + if (site != null && site.Runtime == "WebAssembly") + { + return GetAssemblyList().Select(item => item.HashedName).ToList(); + } + else + { + return new List(); + } } // GET api//load?list=x,y [HttpGet("load")] public IActionResult Load(string list = "*") { - return File(GetAssemblies(list), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll"); + var alias = _tenantManager.GetAlias(); + var site = _sites.GetSite(alias.SiteId); + if (site != null && site.Runtime == "WebAssembly") + { + return File(GetAssemblies(list), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll"); + } + else + { + return File(GetEmptyZip(), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll"); + } } private List GetAssemblyList() @@ -238,6 +258,18 @@ private byte[] GetZIP(string list) } } + private byte[] GetEmptyZip() + { + using (var stream = new MemoryStream()) + { + using (var zip = new ZipArchive(stream, ZipArchiveMode.Create)) + { + } + + return stream.ToArray(); + } + } + private async Task RegisterContact(string email) { try