예제 #1
0
        private void MakeRarAndParFiles(FileSystemInfo toPost, String nameWithoutExtension,
                                        DirectoryInfo processedFolder, String password)
        {
            Int64 size = toPost.Size();
            var   humanReadableSize = UploadSpeedReport.GetHumanReadableSize(size);

            log.DebugFormat("ToPost size: {0}({1})", size, humanReadableSize);
            var rarSizeRecommendation = configuration.RarNParSettings
                                        .Where(rr => rr.FromSizeBytes < size)
                                        .OrderByDescending(rr => rr.FromSize)
                                        .First();

            log.DebugFormat("Rar and par settings found: [{0},{1},{2}]", rarSizeRecommendation.FromSize, rarSizeRecommendation.RarSize, rarSizeRecommendation.Par2Percentage);
            var      rarWrapper   = new RarWrapper(configuration.InactiveProcessTimeout, configuration.RarLocation);
            DateTime rarStartTime = DateTime.Now;

            rarWrapper.Compress(
                toPost,
                processedFolder,
                nameWithoutExtension,
                Settings.DetermineOptimalRarSize(rarSizeRecommendation.RarSize,
                                                 configuration.YEncLineSize, configuration.YEncLinesPerMessage),
                password,
                configuration.RarExtraParameters);
            if (log.IsInfoEnabled)
            {
                TimeSpan rarTimeElapsed = DateTime.Now - rarStartTime;
                Double   rarSpeed       = (Double)size / rarTimeElapsed.TotalSeconds;
                log.InfoFormat("Rarred {0} of file(s) with a speed of {1}", humanReadableSize, UploadSpeedReport.GetHumanReadableSpeed(rarSpeed));
            }

            var      parWrapper    = new ParWrapper(configuration.InactiveProcessTimeout, configuration.ParLocation, configuration.ParCommandFormat);
            var      processedSize = processedFolder.Size();
            Int32    partSize      = parWrapper.CalculatePartSize(processedSize, configuration.YEncPartSize);
            DateTime parStartTime  = DateTime.Now;
            Boolean  makePar       = true;

            while (makePar && partSize / configuration.YEncPartSize < 10)   //Max 10 loops.
            {
                try
                {
                    parWrapper.CreateParFilesInDirectory(
                        processedFolder, nameWithoutExtension, partSize, rarSizeRecommendation.Par2Percentage, configuration.ParExtraParameters);
                    makePar = false;
                }
                catch (Par2BlockSizeTooSmallException)
                {
                    partSize += configuration.YEncPartSize;
                }
            }
            if (log.IsInfoEnabled)
            {
                TimeSpan parTimeElapsed = DateTime.Now - parStartTime;
                Double   parSpeed       = (Double)size / parTimeElapsed.TotalSeconds;
                log.InfoFormat("Parred {0} of file(s) with a speed of {1}", UploadSpeedReport.GetHumanReadableSize(size), UploadSpeedReport.GetHumanReadableSpeed(parSpeed));
            }
        }
예제 #2
0
        private void MakeRarAndParFiles(FileSystemInfo toPost, String nameWithoutExtension,
                                        DirectoryInfo processedFolder, String password)
        {
            Int64 size = toPost.Size();
            var   rarSizeRecommendation = configuration.RarNParSettings
                                          .Where(rr => rr.FromSizeBytes < size)
                                          .OrderByDescending(rr => rr.FromSize)
                                          .First();
            var rarWrapper = new RarWrapper(configuration.InactiveProcessTimeout, configuration.RarLocation);

            rarWrapper.Compress(
                toPost,
                processedFolder,
                nameWithoutExtension,
                Settings.DetermineOptimalRarSize(rarSizeRecommendation.RarSize,
                                                 configuration.YEncLineSize, configuration.YEncLinesPerMessage),
                password,
                configuration.RarExtraParameters);

            var     parWrapper = new ParWrapper(configuration.InactiveProcessTimeout, configuration.ParLocation);
            Boolean makePar    = true;
            Int32   partSize   = configuration.YEncPartSize;

            while (makePar && partSize / configuration.YEncPartSize < 10)   //Max 10 loops.
            {
                try
                {
                    parWrapper.CreateParFilesInDirectory(
                        processedFolder, nameWithoutExtension, partSize, rarSizeRecommendation.Par2Percentage, configuration.ParExtraParameters);
                    makePar = false;
                }
                catch (Par2BlockSizeTooSmallException)
                {
                    partSize += configuration.YEncPartSize;
                }
            }
        }