public int ClientRun(ClientInfo clientInfo, int pid, string[] args) { var options = clientInfo.Options; var ioStream = clientInfo.IoStream; FileList fList; List <FileStruct> fileList; WinRsync.SetupProtocol(clientInfo); if (options.ProtocolVersion >= 23 && !options.ReadBatch) { ioStream.IoStartMultiplexIn(); } if (options.AmSender) { ioStream.IoStartBufferingOut(); if (options.DeleteMode && !options.DeleteExcluded) { var excl = new Exclude(options); excl.SendExcludeList(ioStream); } if (options.Verbose > 3) { Log.Write("File list sent\n"); } ioStream.Flush(); fList = new FileList(options); fileList = fList.SendFileList(clientInfo, args); if (options.Verbose > 3) { Log.WriteLine("file list sent"); } ioStream.Flush(); var sender = new Sender(options); sender.SendFiles(fileList, clientInfo); ioStream.Flush(); ioStream.WriteInt(-1); return(-1); } options.Dir = args[0]; options.Dir = Path.GetFullPath(options.Dir ?? string.Empty); if (!options.ReadBatch) { var excl = new Exclude(options); excl.SendExcludeList(ioStream); } fList = new FileList(options); fileList = fList.ReceiveFileList(clientInfo); return(Daemon.DoReceive(clientInfo, fileList, null)); }
private static void DoServerSender(ClientInfo clientInfo, string[] args) { var dir = args[0]; var ioStream = clientInfo.IoStream; var options = clientInfo.Options; if (options.Verbose > 2) { Log.Write("Server sender starting"); } if (options.AmDaemon && Config.ModuleIsWriteOnly(options.ModuleId)) { WinRsync.Exit("ERROR: module " + Config.GetModuleName(options.ModuleId) + " is write only", clientInfo); return; } if (!options.RelativePaths && !Util.PushDir(dir)) { WinRsync.Exit("Push_dir#3 " + dir + "failed", clientInfo); return; } var fList = new FileList(options); var fileList = fList.SendFileList(clientInfo, args); if (options.Verbose > 3) { Log.WriteLine("File list sent"); } if (fileList.Count == 0) { WinRsync.Exit("File list is empty", clientInfo); return; } ioStream.IoStartBufferingIn(); ioStream.IoStartBufferingOut(); var sender = new Sender(options); sender.SendFiles(fileList, clientInfo); ioStream.Flush(); WinRsync.Report(clientInfo); if (options.ProtocolVersion >= 24) { ioStream.ReadInt(); } ioStream.Flush(); }
public void DeleteFiles(List <FileStruct> fileList) { var argv = new string[1]; List <FileStruct> localFileList = null; if (_options.CvsExclude) { Exclude.AddCvsExcludes(); } for (var j = 0; j < fileList.Count; j++) { if ((fileList[j].Mode & Options.FlagTopDir) == 0 || !Util.S_ISDIR(fileList[j].Mode)) { continue; } argv[0] = _options.Dir + fileList[j].GetFullName(); var fList = new FileList(_options); if ((localFileList = fList.SendFileList(null, argv)) == null) { continue; } for (var i = localFileList.Count - 1; i >= 0; i--) { if (localFileList[i].BaseName == null) { continue; } localFileList[i].DirName = localFileList[i].DirName.Substring(_options.Dir.Length); if (FileList.FileListFind(fileList, (localFileList[i])) < 0) { localFileList[i].DirName = _options.Dir + localFileList[i].DirName; DeleteOne(localFileList[i].GetFullName(), Util.S_ISDIR(localFileList[i].Mode)); } } } }