Comparing version 2.13.27 to 2.13.28
@@ -124,2 +124,21 @@ "use strict"; | ||
} | ||
async postCancel(domainId, rid) { | ||
const rdoc = await record.get(domainId, rid); | ||
if (rdoc) { | ||
const $set = { | ||
status: builtin_1.STATUS.STATUS_CANCELED, | ||
score: 0, | ||
time: 0, | ||
memory: 0, | ||
testCases: [{ | ||
status: 9, score: 0, time: 0, memory: 0, message: 'score canceled', | ||
}], | ||
}; | ||
await Promise.all([ | ||
record.update(domainId, rid, $set), | ||
bus.emit('record/change', rdoc, $set), | ||
]); | ||
} | ||
this.back(); | ||
} | ||
} | ||
@@ -132,2 +151,5 @@ __decorate([ | ||
], RecordDetailHandler.prototype, "postRejudge", null); | ||
__decorate([ | ||
server_1.param('rid', server_1.Types.ObjectID) | ||
], RecordDetailHandler.prototype, "postCancel", null); | ||
class RecordHackHandler extends server_1.Handler { | ||
@@ -165,6 +187,6 @@ async get(domainId, rid, ufid) { | ||
* @deprecated | ||
* use RecordDetailHandler.postRejudge instead. | ||
*/ | ||
class RecordRejudgeHandler extends server_1.Handler { | ||
async post(domainId, rid) { | ||
this.checkPerm(builtin_1.PERM.PERM_REJUDGE); | ||
const rdoc = await record.get(domainId, rid); | ||
@@ -171,0 +193,0 @@ if (rdoc) { |
@@ -491,2 +491,3 @@ /// <reference types="node" /> | ||
locales: Dict<Dict<string>>; | ||
isFirstWorker: boolean; | ||
}; | ||
@@ -497,5 +498,2 @@ addons: string[]; | ||
} | ||
declare module 'cluster' { | ||
let isFirstWorker: boolean; | ||
} | ||
export {}; |
@@ -260,5 +260,5 @@ "use strict"; | ||
if (yargs_1.argv.firstWorker) | ||
cluster_1.default.isFirstWorker = true; | ||
global.Hydro.isFirstWorker = true; | ||
else | ||
cluster_1.default.isFirstWorker = false; | ||
global.Hydro.isFirstWorker = false; | ||
logger.info(`Worker ${process.pid} Starting`); | ||
@@ -265,0 +265,0 @@ await entry({ entry: 'worker' }); |
@@ -35,3 +35,3 @@ import { Db, FilterQuery } from 'mongodb'; | ||
export declare function prependListener<K extends keyof EventMap>(name: K, listener: EventMap[K]): () => boolean; | ||
export declare function once<K extends keyof EventMap>(name: K, listener: EventMap[K]): () => boolean; | ||
export declare function once<K extends keyof EventMap>(name: K, listener: EventMap[K]): any; | ||
export declare function on<K extends keyof EventMap>(name: K, listener: EventMap[K]): () => boolean; | ||
@@ -38,0 +38,0 @@ export declare function off<K extends keyof EventMap>(name: K, listener: EventMap[K]): boolean; |
@@ -43,6 +43,9 @@ "use strict"; | ||
function once(name, listener) { | ||
const dispose = addListener(name, function _listener(...args) { | ||
let dispose; | ||
function _listener(...args) { | ||
dispose(); | ||
return listener.apply(this, args); | ||
}); | ||
} | ||
_listener.toString = () => `// Once \n${listener.toString()}`; | ||
dispose = addListener(name, _listener); | ||
return dispose; | ||
@@ -76,2 +79,4 @@ } | ||
for (const callback of hooks) { | ||
if (yargs_1.argv.busDetail) | ||
console.log(callback.toString()); | ||
await callback.apply(this, args); | ||
@@ -78,0 +83,0 @@ } |
{ | ||
"name": "hydrooj", | ||
"version": "2.13.27", | ||
"version": "2.13.28", | ||
"bin": "bin/hydrooj.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/loader.js", |
import { ObjectID } from 'mongodb'; | ||
import { PermissionError, RecordNotFoundError } from '../error'; | ||
import { PERM, CONSTANT } from '../model/builtin'; | ||
import { PERM, CONSTANT, STATUS } from '../model/builtin'; | ||
import * as problem from '../model/problem'; | ||
@@ -100,2 +100,23 @@ import * as file from '../model/file'; | ||
} | ||
@param('rid', Types.ObjectID) | ||
async postCancel(domainId: string, rid: ObjectID) { | ||
const rdoc = await record.get(domainId, rid); | ||
if (rdoc) { | ||
const $set = { | ||
status: STATUS.STATUS_CANCELED, | ||
score: 0, | ||
time: 0, | ||
memory: 0, | ||
testCases: [{ | ||
status: 9, score: 0, time: 0, memory: 0, message: 'score canceled', | ||
}], | ||
}; | ||
await Promise.all([ | ||
record.update(domainId, rid, $set), | ||
bus.emit('record/change', rdoc, $set), | ||
]); | ||
} | ||
this.back(); | ||
} | ||
} | ||
@@ -134,2 +155,3 @@ | ||
* @deprecated | ||
* use RecordDetailHandler.postRejudge instead. | ||
*/ | ||
@@ -139,3 +161,2 @@ class RecordRejudgeHandler extends Handler { | ||
async post(domainId: string, rid: ObjectID) { | ||
this.checkPerm(PERM.PERM_REJUDGE); | ||
const rdoc = await record.get(domainId, rid); | ||
@@ -142,0 +163,0 @@ if (rdoc) { |
@@ -572,2 +572,3 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
locales: Dict<Dict<string>>, | ||
isFirstWorker: boolean, | ||
}, | ||
@@ -578,5 +579,1 @@ addons: string[], | ||
} | ||
declare module 'cluster' { | ||
let isFirstWorker: boolean; | ||
} |
@@ -231,4 +231,4 @@ /* eslint-disable no-continue */ | ||
} else { | ||
if (argv.firstWorker) cluster.isFirstWorker = true; | ||
else cluster.isFirstWorker = false; | ||
if (argv.firstWorker) global.Hydro.isFirstWorker = true; | ||
else global.Hydro.isFirstWorker = false; | ||
logger.info(`Worker ${process.pid} Starting`); | ||
@@ -235,0 +235,0 @@ await entry({ entry: 'worker' }); |
@@ -88,6 +88,9 @@ /* eslint-disable no-await-in-loop */ | ||
export function once<K extends keyof EventMap>(name: K, listener: EventMap[K]) { | ||
const dispose = addListener(name, function _listener(...args: any[]) { | ||
let dispose; | ||
function _listener(...args: any[]) { | ||
dispose(); | ||
return listener.apply(this, args); | ||
}); | ||
} | ||
_listener.toString = () => `// Once \n${listener.toString()}`; | ||
dispose = addListener(name, _listener); | ||
return dispose; | ||
@@ -120,2 +123,3 @@ } | ||
for (const callback of hooks) { | ||
if (argv.busDetail) console.log(callback.toString()); | ||
await callback.apply(this, args); | ||
@@ -122,0 +126,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1725716
26013