Files
gott/Endpoints/InfoEndpoint.cs
T
Meleki 5d090e160b feat: Windows-Kompatibilität
- WorkspaceHelper: Zentrale Hilfsmethoden (IsWindows, TempDir, IsSubPathOf,
  GetRelativePath, ShellExecutable, ShellArguments)
- ToolService: execute nutzt cmd.exe auf Windows, GetRelativePath mit
  Forward-Slashes, IsSubPathOf für case-insensitive Pfadprüfung
- SessionEndpoint: /tmp → Path.GetTempPath(), bash → cmd.exe,
  Fire-and-forget via .bat statt systemd-run auf Windows
- ChatService: /tmp → WorkspaceHelper.TempDir
- MemoryService: IsSubPathOf + GetRelativePath
- WorkspaceEndpoint: HandleBrowse zeigt Laufwerke auf Windows,
  IsSubPathOf statt StartsWith
- InfoEndpoint: gott.exe auf Windows, isWindows-Flag in API-Response
- Frontend: File-Explorer mit Laufwerks-Navigation auf Windows
2026-03-09 11:35:04 +01:00

45 lines
1.4 KiB
C#

using System;
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Gott.Endpoints;
public static class InfoEndpoint
{
public static void MapInfoEndpoint(this IEndpointRouteBuilder app)
{
app.MapGet("/api/info", HandleInfo);
}
private static IResult HandleInfo()
{
var assembly = Assembly.GetExecutingAssembly();
var location = assembly.Location;
long buildTime = 0;
if (!string.IsNullOrEmpty(location) && File.Exists(location))
{
var lastWrite = File.GetLastWriteTimeUtc(location);
buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds();
}
else
{
var dir = AppContext.BaseDirectory;
var exeName = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows) ? "gott.exe" : "gott";
var exePath = Path.Combine(dir, exeName);
if (File.Exists(exePath))
{
var lastWrite = File.GetLastWriteTimeUtc(exePath);
buildTime = new DateTimeOffset(lastWrite).ToUnixTimeSeconds();
}
}
var isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows);
return Results.Json(new { buildTime, isWindows });
}
}