mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: export: mark pidFilter as optional
This commit is contained in:
2 files changed
+7
-4
No files matched your search
@@ -730,8 +730,8 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
|||||||
files.push({
|
files.push({
|
||||||
type,
|
type,
|
||||||
name: filename,
|
name: filename,
|
||||||
size: statSync(this.request.files.file.filepath).size,
|
size: file.size,
|
||||||
data: () => this.request.files.file.filepath,
|
data: () => file.filepath,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!this.user.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
|
if (!this.user.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
|
||||||
|
|||||||
@@ -603,11 +603,14 @@ export class ProblemModel {
|
|||||||
if (options.delSource) await fs.remove(tmpdir);
|
if (options.delSource) await fs.remove(tmpdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async export(domainId: string, pidFilter?:string) {
|
static async export(domainId: string, pidFilter = '') {
|
||||||
console.log('Exporting problems...');
|
console.log('Exporting problems...');
|
||||||
const tmpdir = path.join(os.tmpdir(), 'hydro', `${Math.random()}.export`);
|
const tmpdir = path.join(os.tmpdir(), 'hydro', `${Math.random()}.export`);
|
||||||
await fs.mkdir(tmpdir);
|
await fs.mkdir(tmpdir);
|
||||||
const pdocs = await ProblemModel.getMulti(domainId, pidFilter ? { pid: pidFilter } : {}, ProblemModel.PROJECTION_PUBLIC).toArray();
|
const pdocs = await ProblemModel.getMulti(
|
||||||
|
domainId, pidFilter ? { pid: new RegExp(pidFilter) } : {},
|
||||||
|
ProblemModel.PROJECTION_PUBLIC,
|
||||||
|
).toArray();
|
||||||
if (process.env.HYDRO_CLI) logger.info(`Exporting ${pdocs.length} problems`);
|
if (process.env.HYDRO_CLI) logger.info(`Exporting ${pdocs.length} problems`);
|
||||||
for (const pdoc of pdocs) {
|
for (const pdoc of pdocs) {
|
||||||
if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid || (`P${pdoc.docId}`)} (${pdoc.title})`);
|
if (process.env.HYDRO_CLI) logger.info(`Exporting problem ${pdoc.pid || (`P${pdoc.docId}`)} (${pdoc.title})`);
|
||||||
|
|||||||
Reference in new issue
Block a user