Пример #1
0
        private ProcessLogTypeResult ProcessDir(LogSetInfo logSetInfo, LogTypeInfo logTypeInfo, IList <IPlugin> plugins)
        {
            var processingStatistics = new ProcessLogTypeResult();

            foreach (var filePath in Directory.EnumerateFiles(logSetInfo.Path, "*", SearchOption.AllDirectories))
            {
                var normalizedPath = filePath.NormalizePath(logSetInfo.Path);
                if (!logTypeInfo.FileBelongsToThisType(normalizedPath))
                {
                    continue;
                }

                _logger.LogInformation("Processing file {}", normalizedPath);
                var fileSizeBytes     = new FileInfo(filePath).Length;
                var fileTimer         = Stopwatch.StartNew();
                var processFileResult = ProcessFile(filePath, normalizedPath, logTypeInfo, plugins);
                processingStatistics.AddProcessingInfo(fileTimer.Elapsed, fileSizeBytes, processFileResult);

                if (!processFileResult.IsSuccessful)
                {
                    break;
                }

                LogFileProcessingResults(normalizedPath, fileSizeBytes, processFileResult, fileTimer.Elapsed);
            }

            return(processingStatistics);
        }
Пример #2
0
        private ProcessLogTypeResult ProcessZip(LogSetInfo logSetInfo, LogTypeInfo logTypeInfo, IList <IPlugin> plugins)
        {
            var processingStatistics = new ProcessLogTypeResult();

            using var zip = ZipFile.Open(logSetInfo.Path, ZipArchiveMode.Read);
            foreach (var fileEntry in zip.Entries)
            {
                if (!logTypeInfo.FileBelongsToThisType(fileEntry.FullName))
                {
                    continue;
                }

                var fileNameWithPrefix = string.IsNullOrWhiteSpace(logSetInfo.Prefix)
                    ? fileEntry.FullName
                    : $"{logSetInfo.Prefix}/{fileEntry.FullName}";

                _logger.LogInformation("Processing file {logFile}", fileNameWithPrefix);
                var fileTimer         = Stopwatch.StartNew();
                var processFileResult = ProcessZippedFile(fileEntry, fileNameWithPrefix, logTypeInfo, plugins);
                processingStatistics.AddProcessingInfo(fileTimer.Elapsed, fileEntry.Length, processFileResult);

                if (!processFileResult.IsSuccessful)
                {
                    break;
                }

                LogFileProcessingResults(fileNameWithPrefix, fileEntry.Length, processFileResult, fileTimer.Elapsed);
            }

            return(processingStatistics);
        }
Пример #3
0
        private IList <LogSetInfo> EvaluateLogSetStructure(string logSetPath, string tempDirRoot, IProcessingNotificationsCollector processingNotificationsCollector)
        {
            IsDirectory = IsPathADirectory(logSetPath);
            _logger.LogInformation("Provided log set appears to be {logSetType}", IsDirectory ? "directory" : "zip file");

            var rootSetInfo = new LogSetInfo(logSetPath, string.Empty, !IsDirectory, _rootPath);
            var zipInfoList = new List <LogSetInfo> {
                rootSetInfo
            };

            zipInfoList.AddRange(IsDirectory
                ? LookForZippedParts(logSetPath)
                : HandleNestedZips(logSetPath, tempDirRoot, processingNotificationsCollector)
                                 );

            LogSetSizeBytes = IsDirectory
                ? GetDirSize(_rootPath)
                : new FileInfo(_rootPath).Length;

            return(zipInfoList);
        }