Skip to content

Commit

Permalink
Refactor: track download stats and enable HTTP/2
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jan 11, 2025
1 parent 29410eb commit 1b1b2b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Build/lib/fetch-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (!fs.existsSync(CACHE_DIR)) {
fs.mkdirSync(CACHE_DIR, { recursive: true });
}

const agent = new Agent({});
const agent = new Agent({ allowH2: true });

setGlobalDispatcher(agent.compose(
interceptors.retry({
Expand Down
5 changes: 2 additions & 3 deletions Build/lib/parse-filter/domainlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import { fetchAssetsWithout304 } from '../fetch-assets';
import type { Span } from '../../trace';

function domainListLineCb(l: string, set: string[], includeAllSubDomain: boolean, meta: string) {
let line = processLine(l);
const line = processLine(l);
if (!line) return;
line = line.toLowerCase();

const domain = normalizeDomain(line);
if (!domain) return;
Expand All @@ -33,7 +32,7 @@ export function processDomainLists(
domainListsUrl: string, mirrors: string[] | null, includeAllSubDomain = false
) {
return span.traceChildAsync(`process domainlist: ${domainListsUrl}`, async (span) => {
const text = await span.traceChildAsync(`process domainlist: ${domainListsUrl}`, () => fetchAssetsWithout304(
const text = await span.traceChildAsync('download', () => fetchAssetsWithout304(
domainListsUrl,
mirrors
));
Expand Down
2 changes: 1 addition & 1 deletion Build/lib/parse-filter/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function processFilterRules(
allowThirdParty = false
): Promise<{ white: string[], black: string[] }> {
const [white, black, warningMessages] = await parentSpan.traceChild(`process filter rules: ${filterRulesUrl}`).traceAsyncFn(async (span) => {
const text = await fetchAssetsWithout304(filterRulesUrl, fallbackUrls);
const text = await span.traceChildAsync('download', () => fetchAssetsWithout304(filterRulesUrl, fallbackUrls));

const whitelistDomainSets = new Set<string>();
const blacklistDomainSets = new Set<string>();
Expand Down

0 comments on commit 1b1b2b8

Please sign in to comment.