mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: buildContent by default
This commit is contained in:
1 parent
29eff97c1a
commit
0fcbcf4f1a
5 files changed
+27
-4
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.26.23",
|
||||
"version": "2.26.24",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
} from '../service/server';
|
||||
import { isPid, parsePid } from '../lib/validator';
|
||||
import download from '../lib/download';
|
||||
import { buildContent } from '../lib/content';
|
||||
|
||||
const RE_SYZOJ = /(https?):\/\/([^/]+)\/(problem|p)\/([0-9]+)\/?/i;
|
||||
const logger = new Logger('import.syzoj');
|
||||
@@ -142,8 +143,9 @@ class ProblemImportSYZOJHandler extends Handler {
|
||||
text: `${url}download/additional_file`,
|
||||
});
|
||||
}
|
||||
const c = buildContent(content, 'markdown');
|
||||
const docId = await problem.add(
|
||||
domainId, target, p.title, JSON.stringify(content), this.user._id, p.tags || [], hidden,
|
||||
domainId, target, p.title, c, this.user._id, p.tags || [], hidden,
|
||||
);
|
||||
const r = download(`${url}testdata/download`);
|
||||
const file = path.resolve(os.tmpdir(), 'hydro', `import_${domainId}_${docId}.zip`);
|
||||
|
||||
@@ -28,6 +28,7 @@ import { STATUS } from './model/builtin';
|
||||
import RecordModel from './model/record';
|
||||
import StorageModel from './model/storage';
|
||||
import { size } from './lib/misc';
|
||||
import { buildContent } from './lib/content';
|
||||
|
||||
const logger = new Logger('upgrade');
|
||||
type UpgradeScript = void | (() => Promise<boolean | void>);
|
||||
@@ -373,6 +374,25 @@ const scripts: UpgradeScript[] = [
|
||||
}
|
||||
return true;
|
||||
},
|
||||
async function _28_29() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllProblem(['content', 'html'], async (pdoc) => {
|
||||
try {
|
||||
const parsed = JSON.parse(pdoc.content);
|
||||
if (parsed instanceof Array) {
|
||||
await problem.edit(pdoc.domainId, pdoc.docId, { content: buildContent(parsed, pdoc.html ? 'html' : 'markdown') });
|
||||
return;
|
||||
}
|
||||
const res = {};
|
||||
for (const key in parsed) {
|
||||
if (typeof parsed[key] === 'string') res[key] = parsed[key];
|
||||
else res[key] = buildContent(parsed[key]);
|
||||
}
|
||||
await problem.edit(pdoc.domainId, pdoc.docId, { content: JSON.stringify(res) });
|
||||
} catch { }
|
||||
});
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
export default scripts;
|
||||
Reference in new issue
Block a user