- BepInEx status prüfung für FTP hinzugefügt -> prüft ob ein ordner BepInEx im stammverzeichnis vorhanden ist.

- Installation von BepInEx über ftp hinzugefügt -> lädt aktuellste version von github runter und lädt sie hoch, prüft danach ob ordner vorhanden ist indem nochmal CheckBepInEx aufgerufen wird. Lies dabei die Version aus von der DLL -> update prüfung kann somit vorgenommen werden (user manuell sicher somit)

Todo:

-FTP Installation von BepInEx überarbeiten... dauert zu lange aktuell
- Installation von BepInEx lässt aktuell leere ordner außen vor... müssen aber im ftp danach auch vorhanden sein!! (patchers, plugins, cache)
This commit is contained in:
tbS
2025-08-24 15:45:27 +02:00
parent 7afbf78bb0
commit 2c7d442441
5 changed files with 301 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reactive;
@@ -149,6 +150,77 @@ namespace Valheim_Dashboard
}
public async Task EnsureFtpDirectoryExistsAsync(string relativePath)
{
Debug.WriteLine("ensure:" + relativePath);
var segments = relativePath.Trim('/').Split('/');
string path = "";
foreach (var segment in segments)
{
path += "/" + segment;
try
{
// relativePath wird direkt an _currentPath gehängt
var request = CreateFtpWebRequest( path, WebRequestMethods.Ftp.MakeDirectory);
using var resp = (FtpWebResponse)await request.GetResponseAsync();
}
catch (WebException ex)
{
var resp = (FtpWebResponse?)ex.Response;
if (resp != null && resp.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
continue;
else
throw;
}
}
}
public async Task UploadStreamAsync(Stream inputStream, string remoteFilePath)
{
Debug.WriteLine("uploadSteam:" + remoteFilePath);
// 1. Remote-Ordner extrahieren
string remoteDir = Path.GetDirectoryName(remoteFilePath)?.Replace("\\", "/") ?? "/";
// 2. Ordner auf FTP sicherstellen
await EnsureFtpDirectoryExistsAsync(remoteDir);
// 3. Upload starten
var request = CreateFtpWebRequest(remoteFilePath, WebRequestMethods.Ftp.UploadFile);
if (inputStream.CanSeek)
{
request.ContentLength = inputStream.Length;
inputStream.Position = 0;
}
using var requestStream = await request.GetRequestStreamAsync();
await inputStream.CopyToAsync(requestStream);
}
public async Task DownloadStreamAsync(string remoteFilePath, Stream outputStream)
{
var request = CreateFtpWebRequest(remoteFilePath, WebRequestMethods.Ftp.DownloadFile);
using var response = (FtpWebResponse)await request.GetResponseAsync();
using var responseStream = response.GetResponseStream();
if (responseStream == null)
throw new Exception("FTP-Stream konnte nicht geöffnet werden.");
await responseStream.CopyToAsync(outputStream);
outputStream.Position = 0; // sicherstellen, dass Stream am Anfang steht
}
/// <summary>
/// Löscht eine Datei vom FTP-Server (Async).