|
|
@ -407,7 +407,7 @@ export class ProblemModel {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async import(domainId: string, filepath: string, operator: number) {
|
|
|
|
static async import(domainId: string, filepath: string, operator = 1) {
|
|
|
|
let tmpdir = '';
|
|
|
|
let tmpdir = '';
|
|
|
|
let del = false;
|
|
|
|
let del = false;
|
|
|
|
if (filepath.endsWith('.zip')) {
|
|
|
|
if (filepath.endsWith('.zip')) {
|
|
|
@ -482,6 +482,7 @@ export class ProblemModel {
|
|
|
|
await fs.mkdir(tmpdir);
|
|
|
|
await fs.mkdir(tmpdir);
|
|
|
|
const pdocs = await ProblemModel.getMulti(domainId, {}, ProblemModel.PROJECTION_PUBLIC).toArray();
|
|
|
|
const pdocs = await ProblemModel.getMulti(domainId, {}, ProblemModel.PROJECTION_PUBLIC).toArray();
|
|
|
|
for (const pdoc of pdocs) {
|
|
|
|
for (const pdoc of pdocs) {
|
|
|
|
|
|
|
|
if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid} (${pdoc.title})`);
|
|
|
|
const problemPath = path.join(tmpdir, `${pdoc.docId}`);
|
|
|
|
const problemPath = path.join(tmpdir, `${pdoc.docId}`);
|
|
|
|
await fs.mkdir(problemPath);
|
|
|
|
await fs.mkdir(problemPath);
|
|
|
|
const problemYaml = path.join(problemPath, 'problem.yaml');
|
|
|
|
const problemYaml = path.join(problemPath, 'problem.yaml');
|
|
|
|