Merge branch 'feature/TransferPacmanCache' into dev

This commit is contained in:
ProfessionalUwU 2023-06-08 04:03:31 +02:00
commit 88c6d7c284
Signed by: ProfessionalUwU
GPG Key ID: 013AD77C0A9DD3F2
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,13 @@
using Pacserver.Utils;
namespace Pacserver.Tests;
public class TranserFilesTest {
[Fact]
public void TransferPacmanCacheTest() {
string result = PacserverUtils.determinePacmanCacheDirectory();
PacserverUtils.TransferPacmanCache();
//Assert.NotEmpty(Directory.GetFiles("/home/rene/test/"));
}
}

View File

@ -1,3 +1,4 @@
using System.Net.Http.Headers;
using System.Text.RegularExpressions;
namespace Pacserver.Utils;
@ -50,8 +51,18 @@ public class PacserverUtils {
}
public static void transferPacmanCache() {
private static List<String> NewerPackagesAndDatabases = new List<String>();
public static async void TransferPacmanCache() {
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://192.168.0.69:12000/upload?path=/");
MultipartFormDataContent content = new MultipartFormDataContent();
foreach (String PkgOrDb in NewerPackagesAndDatabases) {
content.Add(new ByteArrayContent(File.ReadAllBytes(pacmanCacheDirectory + PkgOrDb)), "path", Path.GetFileName(pacmanCacheDirectory + PkgOrDb));
}
request.Content = content;
await client.SendAsync(request);
}
public static void transferPacmanDatabases() {