AAAAAAAA
This commit is contained in:
parent
ef6a55b385
commit
65ccd57136
@ -22,7 +22,7 @@ namespace DTLib.ConsoleGUI
|
||||
|
||||
void ParseLayoutFile(string layout_file)
|
||||
{
|
||||
DtsodV22 layout = new(File.ReadAllText(layout_file));
|
||||
DtsodV23 layout = new(File.ReadAllText(layout_file));
|
||||
AnchorPoint = (layout[Name]["anchor"][0], layout[Name]["anchor"][1]);
|
||||
Width = layout[Name]["width"];
|
||||
Height = layout[Name]["height"];
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
<Compile Include="ConsoleGUI\Window.cs" />
|
||||
<Compile Include="ConsoleGUI\WindowOld.cs" />
|
||||
<Compile Include="Dtsod\DtsodV22.cs" />
|
||||
<Compile Include="Dtsod\DtsodV23.cs" />
|
||||
<Compile Include="Dtsod\DtsodV21.cs" />
|
||||
<Compile Include="cs9somefix.cs" />
|
||||
<Compile Include="Dtsod\ValueTypes.cs" />
|
||||
@ -53,6 +54,7 @@
|
||||
<Compile Include="Network\OldNetwork.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Hasher.cs" />
|
||||
<Compile Include="SafeMutex.cs" />
|
||||
<Compile Include="SecureRandom.cs" />
|
||||
<Compile Include="SimpleConverter.cs" />
|
||||
<Compile Include="TImer.cs" />
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace DTLib.Dtsod
|
||||
{
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace DTLib.Dtsod
|
||||
{
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using DTLib.Dtsod;
|
||||
using DTLib.Filesystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
@ -130,7 +129,7 @@ namespace DTLib.Network
|
||||
var fileHash = new Hasher().HashFile(filePath);
|
||||
mainSocket.SendPackage(Filesize.ToString().ToBytes());
|
||||
mainSocket.SendPackage(fileHash);
|
||||
if (mainSocket.GetPackage().ToStr() != "ready") throw new Exception("user socket isn't ready");
|
||||
mainSocket.GetAnswer("ready");
|
||||
byte[] buffer = new byte[5120];
|
||||
var hashstr = fileHash.HashToString();
|
||||
int packagesCount = 0;
|
||||
@ -163,6 +162,52 @@ namespace DTLib.Network
|
||||
Debug(new string[] { "g", $" uploaded {BytesUploaded} of {Filesize} bytes\n" });
|
||||
}
|
||||
|
||||
/*public void DownloadByManifest(string manifestString, string dirOnClient, bool overwrite = false, bool delete_excess = false)
|
||||
{
|
||||
if (!dirOnClient.EndsWith("\\")) dirOnClient += "\\";
|
||||
var manifest = new DtsodV23(manifestString);
|
||||
Debug("g", $"found {manifest.Values.Count} files in manifest\n");
|
||||
var hasher = new Hasher();
|
||||
foreach (string fileOnServer in manifest.Keys)
|
||||
{
|
||||
string fileOnClient = dirOnClient + fileOnServer;
|
||||
Debug("b", "file <", "c", fileOnClient, "b", ">... ");
|
||||
if (!File.Exists(fileOnClient))
|
||||
{
|
||||
DebugNoTime("y", "doesn't exist\n");
|
||||
DownloadFile(fileOnServer, fileOnClient);
|
||||
}
|
||||
else if (overwrite && hasher.HashFile(fileOnClient).HashToString() != manifest[fileOnServer])
|
||||
{
|
||||
DebugNoTime("y", "outdated\n");
|
||||
DownloadFile(fileOnServer, fileOnClient);
|
||||
}
|
||||
else DebugNoTime("g", "without changes\n");
|
||||
}
|
||||
// удаление лишних файлов
|
||||
if (delete_excess)
|
||||
{
|
||||
List<string> dirs = new();
|
||||
foreach (string file in Directory.GetAllFiles(dirOnClient, ref dirs))
|
||||
{
|
||||
if (!manifest.ContainsKey(file.Remove(0, dirOnClient.Length)))
|
||||
{
|
||||
Debug("y", $"deleting excess file: {file}\n");
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
// удаление пустых папок
|
||||
/*foreach (string dir in dirs)
|
||||
{
|
||||
if (Directory.Exists(dir) && Directory.GetAllFiles(dir).Count == 0)
|
||||
{
|
||||
Debug("y", $"deleting empty dir: {dir}\n");
|
||||
Directory.Delete(dir);
|
||||
}
|
||||
}*/
|
||||
/*}
|
||||
}*/
|
||||
|
||||
public void DownloadByManifest(string dirOnServer, string dirOnClient, bool overwrite = false, bool delete_excess = false)
|
||||
{
|
||||
if (!dirOnClient.EndsWith("\\")) dirOnClient += "\\";
|
||||
@ -190,8 +235,7 @@ namespace DTLib.Network
|
||||
// удаление лишних файлов
|
||||
if (delete_excess)
|
||||
{
|
||||
List<string> dirs = new();
|
||||
foreach (string file in Directory.GetAllFiles(dirOnClient, ref dirs))
|
||||
foreach (string file in Directory.GetAllFiles(dirOnClient))
|
||||
{
|
||||
if (!manifest.ContainsKey(file.Remove(0, dirOnClient.Length)))
|
||||
{
|
||||
@ -199,15 +243,6 @@ namespace DTLib.Network
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
// удаление пустых папок
|
||||
/*foreach (string dir in dirs)
|
||||
{
|
||||
if (Directory.Exists(dir) && Directory.GetAllFiles(dir).Count == 0)
|
||||
{
|
||||
Debug("y", $"deleting empty dir: {dir}\n");
|
||||
Directory.Delete(dir);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,15 +262,15 @@ namespace DTLib.Network
|
||||
manifestBuilder.Append(hash.HashToString());
|
||||
manifestBuilder.Append("\";\n");
|
||||
}
|
||||
Debug($"g", $" manifest of {dir} created\n");
|
||||
File.WriteAllText(dir + "manifest.dtsod", manifestBuilder.ToString());
|
||||
Log($"g", $" manifest of {dir} created\n");
|
||||
}
|
||||
|
||||
void Debug(params string[] msg)
|
||||
static void Debug(params string[] msg)
|
||||
{
|
||||
if (debug) Log(msg);
|
||||
}
|
||||
void DebugNoTime(params string[] msg)
|
||||
static void DebugNoTime(params string[] msg)
|
||||
{
|
||||
if (debug) LogNoTime(msg);
|
||||
}
|
||||
|
||||
@ -53,5 +53,11 @@ namespace DTLib.Network
|
||||
var rec = socket.GetPackage().ToStr();
|
||||
if (rec != answer) throw new Exception($"GetAnswer() error: invalid answer: <{rec}>");
|
||||
}
|
||||
|
||||
public static byte[] RequestPackage(this Socket socket, byte[] request)
|
||||
{
|
||||
socket.SendPackage(request);
|
||||
return socket.GetPackage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user