mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: support auto delete submission files
This commit is contained in:
1 parent
10950ce8b9
commit
93fd7f97c5
3 files changed
+15
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.11.17",
|
||||
"version": "3.11.18",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
@@ -45,7 +45,7 @@
|
||||
"notp": "^2.0.3",
|
||||
"p-queue": "^7.2.0",
|
||||
"require-resolve-hook": "^1.1.0",
|
||||
"semver": "^7.3.5",
|
||||
"semver": "^7.3.6",
|
||||
"serialize-javascript": "^6.0.0",
|
||||
"sockjs": "^0.3.24",
|
||||
"source-map-support": "^0.5.21",
|
||||
@@ -73,7 +73,7 @@
|
||||
"@types/sockjs": "^0.3.33",
|
||||
"@types/source-map-support": "^0.5.4",
|
||||
"@types/superagent": "^4.1.15",
|
||||
"moment": "^2.29.1",
|
||||
"moment": "^2.29.2",
|
||||
"pm2": "^5.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -102,6 +102,16 @@ export class StorageModel {
|
||||
}
|
||||
|
||||
async function cleanFiles() {
|
||||
const submissionKeepDate = system.get('submission.saveDays');
|
||||
if (submissionKeepDate) {
|
||||
const shouldDelete = moment().subtract(submissionKeepDate, 'day').toDate();
|
||||
const res = await StorageModel.coll.find({
|
||||
path: /^submission\//g,
|
||||
lastModified: { $lt: shouldDelete },
|
||||
}).toArray();
|
||||
const paths = res.map((i) => i.path);
|
||||
await StorageModel.del(paths);
|
||||
}
|
||||
if (system.get('server.keepFiles')) return;
|
||||
let res = await StorageModel.coll.findOneAndDelete({ autoDelete: { $lte: new Date() } });
|
||||
while (res.value) {
|
||||
@@ -122,7 +132,7 @@ bus.once('app/started', async () => {
|
||||
await TaskModel.add({
|
||||
type: 'schedule',
|
||||
subType: 'storage.prune',
|
||||
executeAfter: moment().minute(0).second(0).millisecond(0).toDate(),
|
||||
executeAfter: moment().startOf('hour').toDate(),
|
||||
interval: [1, 'hour'],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ export class Handler extends HandlerCommon {
|
||||
|
||||
async init({ domainId }) {
|
||||
let error;
|
||||
if (!argv.options.benchmark && !this.notUsage) await this.limitRate('global', 10, 88);
|
||||
if (!argv.options.benchmark && !this.notUsage) await this.limitRate('global', 5, 88);
|
||||
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
||||
domain.get(domainId),
|
||||
domain.getByHost(this.request.host),
|
||||
|
||||
Reference in new issue
Block a user