mirror of
https://github.com/SukkaW/Surge.git
synced 2026-09-12 10:34:35 +08:00
Update CDN Hosts
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { fastStringArrayJoin } from 'foxts/fast-string-array-join';
|
||||
import { Buffer } from 'node:buffer';
|
||||
import { createHash } from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import fsp from 'node:fs/promises';
|
||||
|
||||
/**
|
||||
@@ -64,6 +65,21 @@ export async function extractContentHashFromFile(filePath: string): Promise<stri
|
||||
return extractContentHash(await readFileHead(filePath));
|
||||
}
|
||||
|
||||
/** Synchronous variant of {@link extractContentHashFromFile}, for worker threads where blocking is fine */
|
||||
export function extractContentHashFromFileSync(filePath: string): string | null {
|
||||
let fd: number | null = null;
|
||||
try {
|
||||
fd = fs.openSync(filePath, 'r');
|
||||
const buf = Buffer.allocUnsafe(FILE_HEAD_CHUNK_SIZE);
|
||||
const bytesRead = fs.readSync(fd, buf, 0, FILE_HEAD_CHUNK_SIZE, 0);
|
||||
return extractContentHash(buf.toString('utf8', 0, bytesRead));
|
||||
} finally {
|
||||
if (fd !== null) {
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function extractContentHash(fileHead: string): string | null {
|
||||
const markerIndex = fileHead.indexOf(CONTENT_HASH_MARKER_START);
|
||||
if (markerIndex === -1) {
|
||||
|
||||
@@ -5664,3 +5664,6 @@ img.novipnoad.com
|
||||
img.novipnoad.net
|
||||
img.novipnoad.us
|
||||
static.giffgaff.com
|
||||
cdn.dictionary.com
|
||||
cdn.theregister.com
|
||||
image.theregister.com
|
||||
|
||||
Reference in New Issue
Block a user