Merge branch 'feature/TransferPacmanCache' into dev
This commit is contained in:
commit
88c6d7c284
13
src/Pacserver.Tests/TransferFilesTest.cs
Normal file
13
src/Pacserver.Tests/TransferFilesTest.cs
Normal 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/"));
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Pacserver.Utils;
|
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() {
|
public static void transferPacmanDatabases() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user