mirror of
https://github.com/diced/zipline.git
synced 2025-05-11 10:26:05 +02:00
feat: CHUNKS_ENABLED config
This commit is contained in:
parent
5178f762eb
commit
0ac81c887e
5 changed files with 10 additions and 1 deletions
|
@ -136,6 +136,7 @@ export interface ConfigOAuth {
|
||||||
export interface ConfigChunks {
|
export interface ConfigChunks {
|
||||||
max_size: number;
|
max_size: number;
|
||||||
chunks_size: number;
|
chunks_size: number;
|
||||||
|
enabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigMfa {
|
export interface ConfigMfa {
|
||||||
|
|
|
@ -158,6 +158,7 @@ export default function readConfig() {
|
||||||
|
|
||||||
map('CHUNKS_MAX_SIZE', 'human-to-byte', 'chunks.max_size'),
|
map('CHUNKS_MAX_SIZE', 'human-to-byte', 'chunks.max_size'),
|
||||||
map('CHUNKS_CHUNKS_SIZE', 'human-to-byte', 'chunks.chunks_size'),
|
map('CHUNKS_CHUNKS_SIZE', 'human-to-byte', 'chunks.chunks_size'),
|
||||||
|
map('CHUNKS_ENABLED', 'boolean', 'chunks.enabled'),
|
||||||
|
|
||||||
map('MFA_TOTP_ISSUER', 'string', 'mfa.totp_issuer'),
|
map('MFA_TOTP_ISSUER', 'string', 'mfa.totp_issuer'),
|
||||||
map('MFA_TOTP_ENABLED', 'boolean', 'mfa.totp_enabled'),
|
map('MFA_TOTP_ENABLED', 'boolean', 'mfa.totp_enabled'),
|
||||||
|
|
|
@ -201,10 +201,12 @@ const validator = s.object({
|
||||||
.object({
|
.object({
|
||||||
max_size: s.number.default(humanToBytes('90MB')),
|
max_size: s.number.default(humanToBytes('90MB')),
|
||||||
chunks_size: s.number.default(humanToBytes('20MB')),
|
chunks_size: s.number.default(humanToBytes('20MB')),
|
||||||
|
enabled: s.boolean.default(true),
|
||||||
})
|
})
|
||||||
.default({
|
.default({
|
||||||
max_size: humanToBytes('90MB'),
|
max_size: humanToBytes('90MB'),
|
||||||
chunks_size: humanToBytes('20MB'),
|
chunks_size: humanToBytes('20MB'),
|
||||||
|
enabled: true,
|
||||||
}),
|
}),
|
||||||
mfa: s
|
mfa: s
|
||||||
.object({
|
.object({
|
||||||
|
|
|
@ -79,7 +79,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
if (fileMaxViews < 0) return res.badRequest('invalid max views (max views < 0)');
|
if (fileMaxViews < 0) return res.badRequest('invalid max views (max views < 0)');
|
||||||
|
|
||||||
// handle partial uploads before ratelimits
|
// handle partial uploads before ratelimits
|
||||||
if (req.headers['content-range']) {
|
if (req.headers['content-range'] && zconfig.chunks.enabled) {
|
||||||
// parses content-range header (bytes start-end/total)
|
// parses content-range header (bytes start-end/total)
|
||||||
const [start, end, total] = req.headers['content-range']
|
const [start, end, total] = req.headers['content-range']
|
||||||
.replace('bytes ', '')
|
.replace('bytes ', '')
|
||||||
|
|
|
@ -44,6 +44,11 @@ if (!file.lastchunk) {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!config.chunks.enabled) {
|
||||||
|
logger.error('chunks are not enabled, worker should not have been started');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
start();
|
start();
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue