mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Make custom UI with --path argument possible (#915)
* make custom UI with --path argument possible * Move logic from SharedInfo to ArchiKestrel and Fix bug with GET /Api/WWW/Directory * No lazy instantiation * Make set of WebsiteDirectory private and add default value * i think i need to watch this: https://www.youtube.com/watch?v=X4rU02088Xc * Further remove logic from SharedInfo * Use relative path in default * Add comment explaining default value of relative path * Fix bug coming from relative path as default value * Revert changes to version that worked
This commit is contained in:
committed by
Łukasz Domeradzki
parent
b15edf4559
commit
2e37c955a3
@@ -34,6 +34,8 @@ namespace ArchiSteamFarm.IPC {
|
||||
internal static class ArchiKestrel {
|
||||
private const string ConfigurationFile = nameof(IPC) + ".config";
|
||||
|
||||
internal static string WebsiteDirectory { get; private set; } = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory);
|
||||
|
||||
internal static HistoryTarget HistoryTarget { get; private set; }
|
||||
|
||||
private static IWebHost KestrelWebHost;
|
||||
@@ -60,9 +62,14 @@ namespace ArchiSteamFarm.IPC {
|
||||
// The order of dependency injection matters, pay attention to it
|
||||
IWebHostBuilder builder = new WebHostBuilder();
|
||||
|
||||
string customDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.WebsiteDirectory);
|
||||
if (Directory.Exists(customDirectory)) {
|
||||
WebsiteDirectory = customDirectory;
|
||||
}
|
||||
|
||||
// Set default directories
|
||||
builder.UseContentRoot(SharedInfo.HomeDirectory);
|
||||
builder.UseWebRoot(SharedInfo.WebsiteDirectory);
|
||||
builder.UseWebRoot(WebsiteDirectory);
|
||||
|
||||
// Check if custom config is available
|
||||
string absoluteConfigDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.ConfigDirectory);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
|
||||
return BadRequest(new GenericResponse<HashSet<string>>(false, string.Format(Strings.ErrorIsEmpty, nameof(directory))));
|
||||
}
|
||||
|
||||
string directoryPath = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.WebsiteDirectory, directory);
|
||||
string directoryPath = Path.Combine(ArchiKestrel.WebsiteDirectory, directory);
|
||||
if (!Directory.Exists(directoryPath)) {
|
||||
return BadRequest(new GenericResponse<HashSet<string>>(false, string.Format(Strings.ErrorIsInvalid, directory)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user