Merge remote-tracking branch 'upstream/cuttingedge' into cuttingedge
This commit is contained in:
commit
0d5db15f87
45
.github/workflows/docker-image-dev.yml
vendored
Normal file
45
.github/workflows/docker-image-dev.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
name: Docker Image CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "dev" ]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
# https://github.com/docker/setup-qemu-action#usage
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2.2.0
|
||||||
|
|
||||||
|
# https://github.com/marketplace/actions/docker-setup-buildx
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v3.1.0
|
||||||
|
|
||||||
|
# https://github.com/docker/login-action#docker-hub
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
# https://github.com/docker/build-push-action#multi-platform-image
|
||||||
|
- name: Build and push API
|
||||||
|
uses: docker/build-push-action@v4.1.1
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
#platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
|
||||||
|
platforms: linux/amd64
|
||||||
|
pull: true
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
glax/tranga-api:dev
|
@ -44,8 +44,8 @@ internal sealed class TrangaCli : Command<TrangaCli.Settings>
|
|||||||
if(settings.fileLogger is true)
|
if(settings.fileLogger is true)
|
||||||
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
||||||
|
|
||||||
string? logFilePath = settings.fileLoggerPath ?? "";
|
string? logFolderPath = settings.fileLoggerPath ?? "";
|
||||||
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, logFilePath);
|
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, logFolderPath);
|
||||||
|
|
||||||
TrangaSettings? trangaSettings = null;
|
TrangaSettings? trangaSettings = null;
|
||||||
|
|
||||||
|
@ -20,17 +20,17 @@ public class Logger : TextWriter
|
|||||||
private readonly FormattedConsoleLogger? _formattedConsoleLogger;
|
private readonly FormattedConsoleLogger? _formattedConsoleLogger;
|
||||||
private readonly MemoryLogger _memoryLogger;
|
private readonly MemoryLogger _memoryLogger;
|
||||||
|
|
||||||
public Logger(LoggerType[] enabledLoggers, TextWriter? stdOut, Encoding? encoding, string? logFilePath)
|
public Logger(LoggerType[] enabledLoggers, TextWriter? stdOut, Encoding? encoding, string? logFolderPath)
|
||||||
{
|
{
|
||||||
this.Encoding = encoding ?? Encoding.UTF8;
|
this.Encoding = encoding ?? Encoding.UTF8;
|
||||||
if(enabledLoggers.Contains(LoggerType.FileLogger) && (logFilePath is null || logFilePath == ""))
|
|
||||||
{
|
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
logFilePath = Path.Join(LogDirectoryPath,
|
if(enabledLoggers.Contains(LoggerType.FileLogger) && (logFolderPath is null || logFolderPath == ""))
|
||||||
|
{
|
||||||
|
string filePath = Path.Join(LogDirectoryPath,
|
||||||
$"{now.ToShortDateString()}_{now.Hour}-{now.Minute}-{now.Second}.log");
|
$"{now.ToShortDateString()}_{now.Hour}-{now.Minute}-{now.Second}.log");
|
||||||
_fileLogger = new FileLogger(logFilePath, encoding);
|
_fileLogger = new FileLogger(filePath, encoding);
|
||||||
}else if (enabledLoggers.Contains(LoggerType.FileLogger) && logFilePath is not null)
|
}else if (enabledLoggers.Contains(LoggerType.FileLogger) && logFolderPath is not null)
|
||||||
_fileLogger = new FileLogger(logFilePath, encoding);
|
_fileLogger = new FileLogger(Path.Join(logFolderPath, $"{now.ToShortDateString()}_{now.Hour}-{now.Minute}-{now.Second}.log") , encoding);
|
||||||
|
|
||||||
|
|
||||||
if (enabledLoggers.Contains(LoggerType.ConsoleLogger) && stdOut is not null)
|
if (enabledLoggers.Contains(LoggerType.ConsoleLogger) && stdOut is not null)
|
||||||
@ -43,6 +43,7 @@ public class Logger : TextWriter
|
|||||||
throw new ArgumentException($"stdOut can not be null for LoggerType {LoggerType.ConsoleLogger}");
|
throw new ArgumentException($"stdOut can not be null for LoggerType {LoggerType.ConsoleLogger}");
|
||||||
}
|
}
|
||||||
_memoryLogger = new MemoryLogger(encoding);
|
_memoryLogger = new MemoryLogger(encoding);
|
||||||
|
WriteLine(GetType().ToString(), $"Logfile: {logFilePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteLine(string caller, string? value)
|
public void WriteLine(string caller, string? value)
|
||||||
|
@ -206,6 +206,9 @@ public class Server : GlobalBase
|
|||||||
case "Settings/customRequestLimit":
|
case "Settings/customRequestLimit":
|
||||||
SendResponse(HttpStatusCode.OK, response, settings.requestLimits);
|
SendResponse(HttpStatusCode.OK, response, settings.requestLimits);
|
||||||
break;
|
break;
|
||||||
|
case "Settings/AprilFoolsMode":
|
||||||
|
SendResponse(HttpStatusCode.OK, response, settings.aprilFoolsMode);
|
||||||
|
break;
|
||||||
case "NotificationConnectors":
|
case "NotificationConnectors":
|
||||||
SendResponse(HttpStatusCode.OK, response, notificationConnectors);
|
SendResponse(HttpStatusCode.OK, response, notificationConnectors);
|
||||||
break;
|
break;
|
||||||
@ -397,7 +400,7 @@ public class Server : GlobalBase
|
|||||||
case "Settings/UpdateDownloadLocation":
|
case "Settings/UpdateDownloadLocation":
|
||||||
if (!requestVariables.TryGetValue("downloadLocation", out string? downloadLocation) ||
|
if (!requestVariables.TryGetValue("downloadLocation", out string? downloadLocation) ||
|
||||||
!requestVariables.TryGetValue("moveFiles", out string? moveFilesStr) ||
|
!requestVariables.TryGetValue("moveFiles", out string? moveFilesStr) ||
|
||||||
!Boolean.TryParse(moveFilesStr, out bool moveFiles))
|
!bool.TryParse(moveFilesStr, out bool moveFiles))
|
||||||
{
|
{
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
@ -405,6 +408,16 @@ public class Server : GlobalBase
|
|||||||
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
settings.UpdateDownloadLocation(downloadLocation, moveFiles);
|
||||||
SendResponse(HttpStatusCode.Accepted, response);
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
break;
|
break;
|
||||||
|
case "Settings/AprilFoolsMode":
|
||||||
|
if (!requestVariables.TryGetValue("enabled", out string? aprilFoolsModeEnabledStr) ||
|
||||||
|
bool.TryParse(aprilFoolsModeEnabledStr, out bool aprilFoolsModeEnabled))
|
||||||
|
{
|
||||||
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
settings.UpdateAprilFoolsMode(aprilFoolsModeEnabled);
|
||||||
|
SendResponse(HttpStatusCode.Accepted, response);
|
||||||
|
break;
|
||||||
/*case "Settings/UpdateWorkingDirectory":
|
/*case "Settings/UpdateWorkingDirectory":
|
||||||
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
if (!requestVariables.TryGetValue("workingDirectory", out string? workingDirectory))
|
||||||
{
|
{
|
||||||
|
@ -73,10 +73,23 @@ public partial class Tranga : GlobalBase
|
|||||||
{
|
{
|
||||||
while (keepRunning)
|
while (keepRunning)
|
||||||
{
|
{
|
||||||
|
if(!settings.aprilFoolsMode || !IsAprilFirst())
|
||||||
jobBoss.CheckJobs();
|
jobBoss.CheckJobs();
|
||||||
|
else
|
||||||
|
Log("April Fools Mode in Effect");
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.Start();
|
t.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsAprilFirst()
|
||||||
|
{
|
||||||
|
//UTC 01 Apr +-12hrs
|
||||||
|
DateTime start = new DateTime(DateTime.Now.Year, 03, 31, 12, 0, 0, DateTimeKind.Utc);
|
||||||
|
DateTime end = new DateTime(DateTime.Now.Year, 04, 02, 12, 0, 0, DateTimeKind.Utc);
|
||||||
|
if (DateTime.UtcNow > start && DateTime.UtcNow < end)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
@ -17,16 +17,16 @@ public partial class Tranga : GlobalBase
|
|||||||
|
|
||||||
string[]? consoleLogger = GetArg(args, ArgEnum.ConsoleLogger);
|
string[]? consoleLogger = GetArg(args, ArgEnum.ConsoleLogger);
|
||||||
string[]? fileLogger = GetArg(args, ArgEnum.FileLogger);
|
string[]? fileLogger = GetArg(args, ArgEnum.FileLogger);
|
||||||
string? filePath = GetArg(args, ArgEnum.FileLoggerPath)?[0];
|
string? directoryPath = GetArg(args, ArgEnum.FileLoggerPath)?[0];
|
||||||
if (filePath is not null && !Directory.Exists(new FileInfo(filePath).DirectoryName))
|
if (directoryPath is not null && !Directory.Exists(directoryPath))
|
||||||
Directory.CreateDirectory(new FileInfo(filePath).DirectoryName!);
|
Directory.CreateDirectory(directoryPath);
|
||||||
|
|
||||||
List<Logger.LoggerType> enabledLoggers = new();
|
List<Logger.LoggerType> enabledLoggers = new();
|
||||||
if(consoleLogger is not null)
|
if(consoleLogger is not null)
|
||||||
enabledLoggers.Add(Logger.LoggerType.ConsoleLogger);
|
enabledLoggers.Add(Logger.LoggerType.ConsoleLogger);
|
||||||
if (fileLogger is not null)
|
if (fileLogger is not null)
|
||||||
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
enabledLoggers.Add(Logger.LoggerType.FileLogger);
|
||||||
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, filePath);
|
Logger logger = new(enabledLoggers.ToArray(), Console.Out, Console.OutputEncoding, directoryPath);
|
||||||
|
|
||||||
TrangaSettings? settings = null;
|
TrangaSettings? settings = null;
|
||||||
string[]? downloadLocationPath = GetArg(args, ArgEnum.DownloadLocation);
|
string[]? downloadLocationPath = GetArg(args, ArgEnum.DownloadLocation);
|
||||||
@ -109,7 +109,7 @@ public partial class Tranga : GlobalBase
|
|||||||
{ ArgEnum.WorkingDirectory, new(new []{"-w", "--workingDirectory"}, 1, "Directory in which application-data is saved") },
|
{ ArgEnum.WorkingDirectory, new(new []{"-w", "--workingDirectory"}, 1, "Directory in which application-data is saved") },
|
||||||
{ ArgEnum.ConsoleLogger, new(new []{"-c", "--consoleLogger"}, 0, "Enables the consoleLogger") },
|
{ ArgEnum.ConsoleLogger, new(new []{"-c", "--consoleLogger"}, 0, "Enables the consoleLogger") },
|
||||||
{ ArgEnum.FileLogger, new(new []{"-f", "--fileLogger"}, 0, "Enables the fileLogger") },
|
{ ArgEnum.FileLogger, new(new []{"-f", "--fileLogger"}, 0, "Enables the fileLogger") },
|
||||||
{ ArgEnum.FileLoggerPath, new (new []{"-l", "--fPath"}, 1, "LogFilePath" ) },
|
{ ArgEnum.FileLoggerPath, new (new []{"-l", "--fPath"}, 1, "Log Folder Path" ) },
|
||||||
{ ArgEnum.Help, new(new []{"-h", "--help"}, 0, "Print this") }
|
{ ArgEnum.Help, new(new []{"-h", "--help"}, 0, "Print this") }
|
||||||
//{ ArgEnum., new(new []{""}, 1, "") }
|
//{ ArgEnum., new(new []{""}, 1, "") }
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Tranga.LibraryConnectors;
|
using Tranga.LibraryConnectors;
|
||||||
using Tranga.MangaConnectors;
|
using Tranga.MangaConnectors;
|
||||||
@ -13,14 +12,15 @@ public class TrangaSettings
|
|||||||
public string downloadLocation { get; private set; }
|
public string downloadLocation { get; private set; }
|
||||||
public string workingDirectory { get; private set; }
|
public string workingDirectory { get; private set; }
|
||||||
public int apiPortNumber { get; init; }
|
public int apiPortNumber { get; init; }
|
||||||
public string userAgent { get; set; } = DefaultUserAgent;
|
public string userAgent { get; private set; } = DefaultUserAgent;
|
||||||
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
|
||||||
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
|
||||||
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
|
||||||
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
[JsonIgnore] public string jobsFolderPath => Path.Join(workingDirectory, "jobs");
|
||||||
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
[JsonIgnore] public string coverImageCache => Path.Join(workingDirectory, "imageCache");
|
||||||
[JsonIgnore] internal static readonly string DefaultUserAgent = $"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
|
[JsonIgnore] internal static readonly string DefaultUserAgent = $"Tranga ({Enum.GetName(Environment.OSVersion.Platform)}; {(Environment.Is64BitOperatingSystem ? "x64" : "")}) / 1.0";
|
||||||
public ushort? version { get; set; } = 1;
|
public ushort? version { get; } = 1;
|
||||||
|
public bool aprilFoolsMode { get; private set; } = true;
|
||||||
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
[JsonIgnore]internal static readonly Dictionary<RequestType, int> DefaultRequestLimits = new ()
|
||||||
{
|
{
|
||||||
{RequestType.MangaInfo, 250},
|
{RequestType.MangaInfo, 250},
|
||||||
@ -102,6 +102,12 @@ public class TrangaSettings
|
|||||||
})!;
|
})!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateAprilFoolsMode(bool enabled)
|
||||||
|
{
|
||||||
|
this.aprilFoolsMode = enabled;
|
||||||
|
ExportSettings();
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
public void UpdateDownloadLocation(string newPath, bool moveFiles = true)
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
Loading…
Reference in New Issue
Block a user