Skip to content

Commit

Permalink
#20 Problem identification: plugin cache is written relative to the e…
Browse files Browse the repository at this point in the history
…xecution directory and the execution directory is a read-only file system
  • Loading branch information
TimoWolters committed Oct 6, 2021
1 parent c232794 commit e89b6fa
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/LotsenApp.Client.Electron/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var pathTask =
Task.Run(async () =>
{
if (Mode != ApplicationMode.Desktop)
{
return Guid.NewGuid().ToString();
}

return await ElectronNET.API.Electron.App.GetPathAsync(PathName.UserData);
});
pathTask.Wait(TimeSpan.FromSeconds(10));
var path = pathTask.Result;

var mvcBuilder = services.AddMvc(option => option.EnableEndpointRouting = false);
services.AddLogging();

Expand All @@ -75,6 +88,7 @@ public void ConfigureServices(IServiceCollection services)
var logger = serviceProvider.GetService<ILogger<PluginManager>>();
if (pluginManager != null)
{
pluginManager.PluginFilePath = path;
#if DEBUG
if (Mode == ApplicationMode.Server)
{
Expand Down Expand Up @@ -106,20 +120,7 @@ public void ConfigureServices(IServiceCollection services)
throw new Exception("The FileService must not be null");
}

Task.WaitAll(new[]
{
Task.Run(async () =>
{
if (Mode != ApplicationMode.Desktop)
{
return;
}
logger.LogDebug("Receiving data directory from electron");
var rootPath = await ElectronNET.API.Electron.App.GetPathAsync(PathName.UserData);
fileService.Root = rootPath;
logger.LogDebug($"Data will be stored in {rootPath}");
})
}, TimeSpan.FromSeconds(10));
fileService.Root = path;
logger.LogDebug("Setting up application encryption");
// Use Root-Path
var keyDirectory = fileService.Join("config/keys");
Expand Down

0 comments on commit e89b6fa

Please sign in to comment.