6 Commits

Author SHA1 Message Date
972cba69ec JsonIgnore
And better working directory stuff
2023-05-22 02:06:49 +02:00
962fe9529e Merge remote-tracking branch 'origin/master' 2023-05-22 01:53:36 +02:00
da1b0cb1cd Change to CommonApplicationFolder as applicationPath 2023-05-22 01:53:27 +02:00
7f88e57e47 Change to CommonApplicationFolder as applicationPath 2023-05-22 01:49:53 +02:00
8865bf284f Corrected applicationFolder in API 2023-05-22 01:42:53 +02:00
5fc2de5fcb logging 2023-05-22 01:20:32 +02:00
4 changed files with 15 additions and 25 deletions

View File

@ -1,8 +1,8 @@
using Logging;
using Tranga;
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga-API");
string applicationFolderPath =
Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Tranga-API");
string logsFolderPath = Path.Join(applicationFolderPath, "logs");
string logFilePath = Path.Join(logsFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt");
string settingsFilePath = Path.Join(applicationFolderPath, "settings.json");
@ -20,7 +20,7 @@ TrangaSettings settings;
if (File.Exists(settingsFilePath))
settings = TrangaSettings.LoadSettings(settingsFilePath);
else
settings = new TrangaSettings(Directory.GetCurrentDirectory(), settingsFilePath, null);
settings = new TrangaSettings(Directory.GetCurrentDirectory(), applicationFolderPath, null);
TaskManager taskManager = new (settings, logger);
@ -103,20 +103,8 @@ app.MapDelete("/Queue/Dequeue", (string taskType, string? connectorName, string?
taskManager.RemoveTaskFromQueue(task);
});
app.MapGet("/Settings/Get", () => new Settings(taskManager.settings));
app.MapGet("/Settings/Get", () => taskManager.settings);
app.MapPost("/Settings/Update", (string? downloadLocation, string? komgaUrl, string? komgaAuth) => taskManager.UpdateSettings(downloadLocation, komgaUrl, komgaAuth) );
app.Run();
class Settings
{
public string downloadLocation { get; }
public Komga? komga { get; }
public Settings(TrangaSettings settings)
{
this.downloadLocation = settings.downloadLocation;
this.komga = settings.komga;
}
}
app.Run();

View File

@ -14,7 +14,7 @@ public static class Tranga_Cli
{
public static void Main(string[] args)
{
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga");
string applicationFolderPath = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Tranga");
string logsFolderPath = Path.Join(applicationFolderPath, "logs");
string logFilePath = Path.Join(logsFolderPath, $"log-{DateTime.Now:dd-M-yyyy-HH-mm-ss}.txt");
string settingsFilePath = Path.Join(applicationFolderPath, "settings.json");

View File

@ -213,7 +213,10 @@ public class MangaDex : Connector
DirectoryInfo dirInfo = new (publicationFolder);
foreach(FileInfo fileInfo in dirInfo.EnumerateFiles())
if (fileInfo.Name.Contains("cover."))
{
logger?.WriteLine(this.GetType().ToString(), $"Cover exists {publication.sortName}");
return;
}
//Request information where to download Cover
DownloadClient.RequestResult requestResult =

View File

@ -6,15 +6,14 @@ public class TrangaSettings
{
public string downloadLocation { get; set; }
public string workingDirectory { get; set; }
public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
public string tasksFilePath => Path.Join(workingDirectory, "tasks.json");
public string knownPublicationsPath => Path.Join(workingDirectory, "knownPublications.json");
[JsonIgnore]public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
[JsonIgnore]public string tasksFilePath => Path.Join(workingDirectory, "tasks.json");
[JsonIgnore]public string knownPublicationsPath => Path.Join(workingDirectory, "knownPublications.json");
public Komga? komga { get; set; }
public TrangaSettings(string downloadLocation, string? workingDirectory, Komga? komga)
public TrangaSettings(string downloadLocation, string workingDirectory, Komga? komga)
{
this.workingDirectory = workingDirectory ??
Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Tranga");
this.workingDirectory = workingDirectory;
this.downloadLocation = downloadLocation;
this.komga = komga;
}
@ -22,7 +21,7 @@ public class TrangaSettings
public static TrangaSettings LoadSettings(string importFilePath)
{
if (!File.Exists(importFilePath))
return new TrangaSettings(Directory.GetCurrentDirectory(), null, null);
return new TrangaSettings(Path.Join(Directory.GetCurrentDirectory(), "Downloads"), Directory.GetCurrentDirectory(), null);
string toRead = File.ReadAllText(importFilePath);
TrangaSettings settings = JsonConvert.DeserializeObject<TrangaSettings>(toRead)!;