mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 20:08:19 +02:00
Rework TrangaSettings
This commit is contained in:
@@ -36,34 +36,14 @@ public partial class Tranga : GlobalBase
|
||||
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
||||
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, directoryPath);
|
||||
|
||||
TrangaSettings? settings = null;
|
||||
bool dlp = fetched.TryGetValue(downloadLocation, out string[]? downloadLocationPath);
|
||||
bool wdp = fetched.TryGetValue(downloadLocation, out string[]? workingDirectoryPath);
|
||||
bool wdp = fetched.TryGetValue(workingDirectory, out string[]? workingDirectoryPath);
|
||||
|
||||
if (dlp && wdp)
|
||||
{
|
||||
settings = new TrangaSettings(downloadLocationPath![0], workingDirectoryPath![0]);
|
||||
}else if (dlp)
|
||||
{
|
||||
if (settings is null)
|
||||
settings = new TrangaSettings(downloadLocation: downloadLocationPath![0]);
|
||||
else
|
||||
settings = new TrangaSettings(downloadLocation: downloadLocationPath![0], settings.workingDirectory);
|
||||
}else if (wdp)
|
||||
{
|
||||
if (settings is null)
|
||||
settings = new TrangaSettings(downloadLocation: workingDirectoryPath![0]);
|
||||
else
|
||||
settings = new TrangaSettings(settings.downloadLocation, workingDirectoryPath![0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings = new TrangaSettings();
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(settings.downloadLocation);//TODO validate path
|
||||
Directory.CreateDirectory(settings.workingDirectory);//TODO validate path
|
||||
if (wdp)
|
||||
TrangaSettings.LoadFromWorkingDirectory(workingDirectoryPath![0]);
|
||||
if(dlp)
|
||||
TrangaSettings.CreateOrUpdate(downloadDirectory: downloadLocationPath![0]);
|
||||
|
||||
Tranga _ = new (logger, settings);
|
||||
Tranga _ = new (logger);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user