<commit_before>const path = require('path');
const pathToRegexp = require('path-to-regexp');
const co = require('co');
const { fs, system, encrypt } = require('@foxman/helpers');
const logger = require('./logger');
const TaskLock = require('task-lock');
const extname = path.extname;
const { lstat, readFile } = fs;
const { notify } = system;

function noop(p) {
    return p;
}

function dispatcher({ processor, reloaderService, resourcesManager }) {
    const taskLock = new TaskLock();
    return function() {
        return function*(next) {
            const reqPath = this.request.path;
            if (
                !isPathMatched({
                    pattern: processor.match,
                    reqPath
                })
            ) {
                return yield next;
            }

            if (resourcesManager.has(reqPath)) {
                logger.info(`Served by resourcesManager - ${reqPath}`);

                const ifNoneMatch = this.req.headers['if-none-match'];
                const content = resourcesManager.get(reqPath);
                const eTag = encrypt.md5(content);

                this.type = extname(reqPath);

                if (ifNoneMatch && ifNoneMatch === eTag) {
                    this.status = 304;
                    this.body = '';
                    this.set('ETag', eTag);
                } else {
                    this.status = 200;
                    this.body = content;
                }
                return;
            }

            const { pipeline = [], lockTask = false } = processor;
            const processdFilenameStack = getSemiFinished({<commit_msg>feat: 当前标签页不在可见页面时，不进行 relaod<commit_after>const path = require('path');
const pathToRegexp = require('path-to-regexp');
const co = require('co');
const { fs, system, encrypt } = require('@foxman/helpers');
const logger = require('./logger');
const TaskLock = require('task-lock');
const extname = path.extname;
const { lstat, readFile } = fs;
const { notify } = system;

function noop(p) {
    return p;
}

function dispatcher({ processor, reloaderService, resourcesManager }) {
    const taskLock = new TaskLock();
    return function() {
        return function*(next) {
            const reqPath = this.request.path;
            if (
                !isPathMatched({
                    pattern: processor.match,
                    reqPath
                })
            ) {
                return yield next;
            }

            if (resourcesManager.has(reqPath)) {
                logger.info(`Served by resourcesManager - ${reqPath}`);

                const ifNoneMatch = this.req.headers['if-none-match'];
                const content = resourcesManager.get(reqPath);
                const eTag = encrypt.md5(content);

                this.type = extname(reqPath);

                if (ifNoneMatch && ifNoneMatch === eTag) {
                    this.status = 304;
                    this.body = '';
                } else {
                    this.status = 200;
                    this.body = content;
                }

                this.set('ETag', eTag);
                return;
            }

            const { pipeline = [], lockTask = false } = processor;
            const processdFilenameStack = getSemiFinished({
{'fraction_non_alphanumeric': 0.11574779165397503, 'fraction_numerical': 0.0042643923240938165, 'mean_word_length': 1.6063492063492064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1209688', 'n_tokens_mistral': 895, 'n_tokens_neox': 837, 'n_words': 197}