mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Fix: drop corrupted files
This commit is contained in:
parent
3b91b69406
commit
4522c8c963
@ -2,7 +2,7 @@ import path from 'node:path';
|
|||||||
import { pipeline } from 'node:stream/promises';
|
import { pipeline } from 'node:stream/promises';
|
||||||
import { task } from './trace';
|
import { task } from './trace';
|
||||||
import { defaultRequestInit, fetchWithRetry } from './lib/fetch-retry';
|
import { defaultRequestInit, fetchWithRetry } from './lib/fetch-retry';
|
||||||
import { extract as tarExtract } from 'tar-fs';
|
import { extract as tarExtract, type Headers as TarEntryHeaders } from 'tar-fs';
|
||||||
import zlib from 'node:zlib';
|
import zlib from 'node:zlib';
|
||||||
import { Readable } from 'node:stream';
|
import { Readable } from 'node:stream';
|
||||||
|
|
||||||
@ -62,9 +62,7 @@ export const downloadPreviousBuild = task(require.main === module, __filename)(a
|
|||||||
const extract = tarExtract(
|
const extract = tarExtract(
|
||||||
publicDir,
|
publicDir,
|
||||||
{
|
{
|
||||||
ignore(_, header) {
|
ignore: tarOnIgnore,
|
||||||
return header?.type !== 'file' && header?.type !== 'directory';
|
|
||||||
},
|
|
||||||
map(header) {
|
map(header) {
|
||||||
header.name = header.name.replace(pathPrefix, '');
|
header.name = header.name.replace(pathPrefix, '');
|
||||||
return header;
|
return header;
|
||||||
@ -79,3 +77,18 @@ export const downloadPreviousBuild = task(require.main === module, __filename)(a
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function tarOnIgnore(_: string, header?: TarEntryHeaders) {
|
||||||
|
if (header) {
|
||||||
|
if (header.type !== 'file' && header.type !== 'directory') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const extname = path.extname(header.name);
|
||||||
|
if (extname === '.ts') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
/* global $request, $response, $done */
|
|
||||||
|
|
||||||
const url = $request.url;
|
|
||||||
const body = url.endsWith('region') || url.endsWith('region/')
|
|
||||||
? 'OK'
|
|
||||||
: $response.body;
|
|
||||||
|
|
||||||
if ($request.method === 'OPTION') {
|
|
||||||
$done({});
|
|
||||||
} else {
|
|
||||||
$done({
|
|
||||||
status: 200,
|
|
||||||
body,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'text/plain; charset=utf-8',
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Credentials': '*',
|
|
||||||
'Access-Control-Allow-Headers': 'origin,range,hdntl,hdnts',
|
|
||||||
'Access-Control-Allow-Methods': 'GET,HEAD,POST,PUT,DELETE,OPTIONS',
|
|
||||||
'Access-Control-Expose-Headers': 'Server,range,hdntl,hdnts,Akamai-Mon-Iucid-Ing,Akamai-Mon-Iucid-Del,Akamai-Request-BC',
|
|
||||||
'Access-Control-Max-Age': '86400'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -83,6 +83,7 @@ vuejs.org
|
|||||||
.react.dev
|
.react.dev
|
||||||
.reactjs.org
|
.reactjs.org
|
||||||
.radix-ui.com
|
.radix-ui.com
|
||||||
|
.nextui.org
|
||||||
storybook.js.org
|
storybook.js.org
|
||||||
www.typescriptlang.org
|
www.typescriptlang.org
|
||||||
typescript.azureedge.net
|
typescript.azureedge.net
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user