Example #1
0
        private void CompressTask(Compressor compressor, string filename)
        {
            var relativePath = Path.GetRelativePath(Path.GetDirectoryName(Input), filename);
            var outputPath   = Path.Join(OutputFolder, Path.ChangeExtension(relativePath, "cbz"));

            if ((File.Exists(outputPath) && Skip) || (!filename.EndsWith(".cbr") && !filename.EndsWith(".cbz")))
            {
                return;
            }

            try
            {
                compressor.Compress(filename, outputPath);
            }
            catch (Exception e)
            {
                Logger.Log("Error processing file: " + filename, LogLevel.Error);
                Logger.LogDebug(e, LogLevel.Error);
            }
        }
Example #2
0
        private void Process(IList <string> files)
        {
            Compressor compressor = new Compressor(Logger, MultiProcessing);

            compressor.Quality = Quality;

            if (!IsParallel)
            {
                foreach (var file in files)
                {
                    CompressTask(compressor, file);
                }
                return;
            }

            Parallel.ForEach(files, new ParallelOptions
            {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, file => CompressTask(compressor, file));
        }