|
|
@ -407,7 +407,9 @@ export class ProblemModel {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async import(domainId: string, filepath: string, operator: number) {
|
|
|
|
static async import(domainId: string, filepath: string, operator: number) {
|
|
|
|
const tmpdir = path.join(os.tmpdir(), 'hydro', `${Math.random()}.import`);
|
|
|
|
let tmpdir = '';
|
|
|
|
|
|
|
|
if (filepath.endsWith('.zip')) {
|
|
|
|
|
|
|
|
tmpdir = path.join(os.tmpdir(), 'hydro', `${Math.random()}.import`);
|
|
|
|
let zip: AdmZip;
|
|
|
|
let zip: AdmZip;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
zip = new AdmZip(filepath);
|
|
|
|
zip = new AdmZip(filepath);
|
|
|
@ -420,6 +422,11 @@ export class ProblemModel {
|
|
|
|
resolve(null);
|
|
|
|
resolve(null);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (fs.statSync(filepath).isDirectory()) {
|
|
|
|
|
|
|
|
tmpdir = filepath;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new ValidationError('file', null, 'Invalid file');
|
|
|
|
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const problems = await fs.readdir(tmpdir, { withFileTypes: true });
|
|
|
|
const problems = await fs.readdir(tmpdir, { withFileTypes: true });
|
|
|
|
for (const p of problems) {
|
|
|
|
for (const p of problems) {
|
|
|
|