Esempio n. 1
0
        public static int DoReceive(ClientInfo cInfo, List <FileStruct> fileList, string localName)
        {
            var f        = cInfo.IoStream;
            var options  = cInfo.Options;
            var receiver = new Receiver(options);

            options.CopyLinks = false;
            f.Flush();
            if (!options.DeleteAfter)
            {
                if (options.Recurse && options.DeleteMode && localName == null && fileList.Count > 0)
                {
                    receiver.DeleteFiles(fileList);
                }
            }
            f.IoStartBufferingOut();
            var gen = new Generator(options);

            gen.GenerateFiles(f, fileList, localName);
            f.Flush();
            if (fileList != null && fileList.Count != 0)
            {
                receiver.ReceiveFiles(cInfo, fileList, localName);
            }
            WinRsync.Report(cInfo);
            if (options.ProtocolVersion >= 24)
            {
                /* send a final goodbye message */
                f.WriteInt(-1);
            }
            f.Flush();
            return(0);
        }
Esempio n. 2
0
        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();
        }