mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
import without pid check, fix bulk, upgrade dep
This commit is contained in:
1 parent
ac9dc00c6a
commit
76f105c4c8
14 files changed
+65
-141
No files matched your search
+4
-4
@@ -19,19 +19,19 @@
|
|||||||
"@types/cross-spawn": "^6.0.2",
|
"@types/cross-spawn": "^6.0.2",
|
||||||
"@types/jest": "^26.0.9",
|
"@types/jest": "^26.0.9",
|
||||||
"@types/node": "^14.0.27",
|
"@types/node": "^14.0.27",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
"@typescript-eslint/eslint-plugin": "^3.9.0",
|
||||||
"@typescript-eslint/parser": "^3.8.0",
|
"@typescript-eslint/parser": "^3.9.0",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"eslint": "^7.6.0",
|
"eslint": "^7.6.0",
|
||||||
"eslint-config-airbnb-base": "^14.2.0",
|
"eslint-config-airbnb-base": "^14.2.0",
|
||||||
"eslint-import-resolver-typescript": "^2.2.0",
|
"eslint-import-resolver-typescript": "^2.2.0",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.22.0",
|
||||||
"globby": "^11.0.1",
|
"globby": "^11.0.1",
|
||||||
"jest": "^26.2.2",
|
"jest": "^26.4.0",
|
||||||
"latest-version": "^5.1.0",
|
"latest-version": "^5.1.0",
|
||||||
"ora": "^5.0.0",
|
"ora": "^5.0.0",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
"ts-jest": "^26.1.4",
|
"ts-jest": "^26.2.0",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^3.9.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"bson": "^4.0.4",
|
"bson": "^4.1.0",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"hydrooj": "^2.12.0",
|
"hydrooj": "^2.12.0",
|
||||||
"js-yaml": "^3.14.0",
|
"js-yaml": "^3.14.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.12.14",
|
"version": "2.12.15",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
"cookies": "^0.8.0",
|
"cookies": "^0.8.0",
|
||||||
"detect-browser": "^5.1.1",
|
"detect-browser": "^5.1.1",
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"html-to-text": "^5.1.1",
|
|
||||||
"js-yaml": "^3.13.1",
|
"js-yaml": "^3.13.1",
|
||||||
"koa": "^2.13.0",
|
"koa": "^2.13.0",
|
||||||
"koa-body": "^4.2.0",
|
"koa-body": "^4.2.0",
|
||||||
@@ -25,29 +24,19 @@
|
|||||||
"koa-static-cache": "^5.1.3",
|
"koa-static-cache": "^5.1.3",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"lru-cache": "^6.0.0",
|
"lru-cache": "^6.0.0",
|
||||||
"markdown-it": "^11.0.0",
|
|
||||||
"markdown-it-anchor": "^5.3.0",
|
|
||||||
"markdown-it-footnote": "^3.0.2",
|
|
||||||
"markdown-it-imsize": "^2.0.1",
|
|
||||||
"markdown-it-mark": "^3.0.0",
|
|
||||||
"markdown-it-table-of-contents": "^0.4.4",
|
|
||||||
"moment-timezone": "^0.5.31",
|
"moment-timezone": "^0.5.31",
|
||||||
"mongodb": "^3.5.9",
|
"mongodb": "^3.5.9",
|
||||||
"nodemailer": "^6.4.10",
|
"nodemailer": "^6.4.10",
|
||||||
"nunjucks": "^3.2.2",
|
|
||||||
"prismjs": "^1.21.0",
|
|
||||||
"proxy-agent": "^3.1.1",
|
|
||||||
"ps-list": "^7.2.0",
|
"ps-list": "^7.2.0",
|
||||||
"serialize-javascript": "^4.0.0",
|
"serialize-javascript": "^4.0.0",
|
||||||
"sockjs": "^0.3.20",
|
"sockjs": "^0.3.20",
|
||||||
"superagent": "^5.3.1",
|
"superagent": "^6.0.0",
|
||||||
"systeminformation": "^4.26.10",
|
"systeminformation": "^4.26.10",
|
||||||
"yargs": "^15.4.1"
|
"yargs": "^15.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/adm-zip": "^0.4.33",
|
"@types/adm-zip": "^0.4.33",
|
||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.1",
|
||||||
"@types/html-to-text": "^5.1.1",
|
|
||||||
"@types/js-yaml": "^3.12.5",
|
"@types/js-yaml": "^3.12.5",
|
||||||
"@types/katex": "^0.11.0",
|
"@types/katex": "^0.11.0",
|
||||||
"@types/koa": "^2.11.3",
|
"@types/koa": "^2.11.3",
|
||||||
@@ -56,11 +45,8 @@
|
|||||||
"@types/koa-static-cache": "^5.1.0",
|
"@types/koa-static-cache": "^5.1.0",
|
||||||
"@types/lodash": "^4.14.158",
|
"@types/lodash": "^4.14.158",
|
||||||
"@types/lru-cache": "^5.1.0",
|
"@types/lru-cache": "^5.1.0",
|
||||||
"@types/markdown-it": "^10.0.1",
|
|
||||||
"@types/mongodb": "^3.5.25",
|
"@types/mongodb": "^3.5.25",
|
||||||
"@types/nodemailer": "^6.4.0",
|
"@types/nodemailer": "^6.4.0",
|
||||||
"@types/nunjucks": "^3.1.3",
|
|
||||||
"@types/prismjs": "^1.16.1",
|
|
||||||
"@types/serialize-javascript": "^4.0.0",
|
"@types/serialize-javascript": "^4.0.0",
|
||||||
"@types/sockjs": "^0.3.32",
|
"@types/sockjs": "^0.3.32",
|
||||||
"@types/superagent": "^4.1.8",
|
"@types/superagent": "^4.1.8",
|
||||||
|
|||||||
@@ -5,17 +5,13 @@ import fs from 'fs-extra';
|
|||||||
import Koa, { Context } from 'koa';
|
import Koa, { Context } from 'koa';
|
||||||
import Body from 'koa-body';
|
import Body from 'koa-body';
|
||||||
import cache from 'koa-static-cache';
|
import cache from 'koa-static-cache';
|
||||||
import nunjucks from 'nunjucks';
|
|
||||||
import mongodb from 'mongodb';
|
import mongodb from 'mongodb';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
|
||||||
const listenPort = argv.port || 8888;
|
const listenPort = argv.port || 8888;
|
||||||
|
|
||||||
class Loader {
|
async function get(ctx: Context) {
|
||||||
getSource(name: string) { // eslint-disable-line class-methods-use-this
|
ctx.body = `<!DOCTYPE html>
|
||||||
return {
|
|
||||||
src: `
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html data-page="setup" data-layout="immersive" class="layout--immersive page--setup nojs">
|
<html data-page="setup" data-layout="immersive" class="layout--immersive page--setup nojs">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
@@ -25,48 +21,48 @@ class Loader {
|
|||||||
<meta name="msapplication-TileColor" content="#579e9a">
|
<meta name="msapplication-TileColor" content="#579e9a">
|
||||||
<meta name="theme-color" content="#56758f">
|
<meta name="theme-color" content="#56758f">
|
||||||
<link rel="stylesheet" media="all" href="/vj4.css">
|
<link rel="stylesheet" media="all" href="/vj4.css">
|
||||||
<title>{{ _('Setup') }}</title>
|
<title>Setup</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="slideout-panel" id="panel">
|
<div class="slideout-panel" id="panel">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<div class="immersive--content immersive--center">
|
<div class="immersive--content immersive--center">
|
||||||
<h1>{{ _('Setup') }}</h1>
|
<h1>Setup</h1>
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<label class="inverse material textbox">
|
<label class="inverse material textbox">
|
||||||
{{ _('Database Host') }}
|
Database Host
|
||||||
<input name="host" type="text" value="127.0.0.1" autofocus>
|
<input name="host" type="text" value="127.0.0.1" autofocus>
|
||||||
</label>
|
</label>
|
||||||
</div></div>
|
</div></div>
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<label class="inverse material textbox">
|
<label class="inverse material textbox">
|
||||||
{{ _('Database Port') }}
|
Database Port
|
||||||
<input name="port" type="number" value="27017">
|
<input name="port" type="number" value="27017">
|
||||||
</label>
|
</label>
|
||||||
</div></div>
|
</div></div>
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<label class="inverse material textbox">
|
<label class="inverse material textbox">
|
||||||
{{ _('Database Name') }}
|
Database Name
|
||||||
<input name="name" type="text" value="hydro">
|
<input name="name" type="text" value="hydro">
|
||||||
</label>
|
</label>
|
||||||
</div></div>
|
</div></div>
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<label class="inverse material textbox">
|
<label class="inverse material textbox">
|
||||||
{{ _('Database Username') }}
|
Database Username
|
||||||
<input name="username" type="text" placeholder="{{ _('Leave blank if none') }}">
|
<input name="username" type="text" placeholder="Leave blank if none">
|
||||||
</label>
|
</label>
|
||||||
</div></div>
|
</div></div>
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<label class="inverse material textbox">
|
<label class="inverse material textbox">
|
||||||
{{ _('Database Password') }}
|
Database Password
|
||||||
<input name="password" type="password" placeholder="{{ _('Leave blank if none') }}">
|
<input name="password" type="password" placeholder="Leave blank if none">
|
||||||
</label>
|
</label>
|
||||||
</div></div>
|
</div></div>
|
||||||
<div class="row"><div class="columns">
|
<div class="row"><div class="columns">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<input type="submit" value="{{ _('Confirm') }}" class="inverse expanded rounded primary button">
|
<input type="submit" value="Confirm" class="inverse expanded rounded primary button">
|
||||||
</div>
|
</div>
|
||||||
</div></div>
|
</div></div>
|
||||||
</form>
|
</form>
|
||||||
@@ -75,29 +71,7 @@ class Loader {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>`;
|
||||||
`,
|
|
||||||
path: name,
|
|
||||||
noCache: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const env = new nunjucks.Environment(new Loader(), { autoescape: true, trimBlocks: true });
|
|
||||||
|
|
||||||
function render(name: string) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
env.render(name, {
|
|
||||||
_: (str: string) => str,
|
|
||||||
}, (err, res) => {
|
|
||||||
if (err) reject(err);
|
|
||||||
else resolve(res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function get(ctx: Context) {
|
|
||||||
ctx.body = await render('setup.html');
|
|
||||||
ctx.response.type = 'text/html';
|
ctx.response.type = 'text/html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ import {
|
|||||||
import { isPid } from '../lib/validator';
|
import { isPid } from '../lib/validator';
|
||||||
|
|
||||||
class ProblemImportHandler extends Handler {
|
class ProblemImportHandler extends Handler {
|
||||||
async prepare() {
|
|
||||||
this.checkPerm(PERM.PERM_CREATE_PROBLEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
async get() {
|
async get() {
|
||||||
this.response.template = 'problem_import.html';
|
this.response.template = 'problem_import.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
@@ -26,7 +22,7 @@ class ProblemImportHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@param('url', Types.String)
|
@param('url', Types.String)
|
||||||
@param('pid', Types.String, isPid)
|
@param('pid', Types.String, true, isPid)
|
||||||
@param('hidden', Types.Boolean)
|
@param('hidden', Types.Boolean)
|
||||||
@param('remoteType', Types.String)
|
@param('remoteType', Types.String)
|
||||||
async post(domainId: string, url: string, pid: string, hidden = false, remoteType: string) {
|
async post(domainId: string, url: string, pid: string, hidden = false, remoteType: string) {
|
||||||
@@ -55,7 +51,7 @@ class ProblemImportHandler extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function apply() {
|
export async function apply() {
|
||||||
Route('problem_import', '/problem/import', ProblemImportHandler);
|
Route('problem_import', '/problem/import', ProblemImportHandler, PERM.PERM_CREATE_PROBLEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
global.Hydro.handler.import = apply;
|
global.Hydro.handler.import = apply;
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import superagent from 'superagent';
|
|
||||||
import proxyAgent from 'proxy-agent';
|
|
||||||
|
|
||||||
namespace Proxy {
|
|
||||||
function getUrl() {
|
|
||||||
return this._url;
|
|
||||||
}
|
|
||||||
function setUrl(v: string) {
|
|
||||||
this._url = v;
|
|
||||||
// eslint-disable-next-line no-use-before-define
|
|
||||||
proxy.call(this, this._proxyUri);
|
|
||||||
}
|
|
||||||
function setupUrl(req: superagent.Request) {
|
|
||||||
const desc = Object.getOwnPropertyDescriptor(req, 'url');
|
|
||||||
if (desc.get === getUrl && desc.set === setUrl) return;
|
|
||||||
// @ts-ignore
|
|
||||||
req._url = req.url;
|
|
||||||
desc.get = getUrl;
|
|
||||||
desc.set = setUrl;
|
|
||||||
delete desc.value;
|
|
||||||
delete desc.writable;
|
|
||||||
Object.defineProperty(req, 'url', desc);
|
|
||||||
}
|
|
||||||
function proxy(uri: string) {
|
|
||||||
if (!uri) return this;
|
|
||||||
setupUrl(this);
|
|
||||||
const agent = proxyAgent(uri);
|
|
||||||
if (agent) this.agent(agent);
|
|
||||||
this._proxyUri = uri;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
export function setup(agent, uri = '') {
|
|
||||||
const Request = agent.Request;
|
|
||||||
if (Request) {
|
|
||||||
Request.prototype.proxy = proxy;
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
return proxy.call(agent, uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'superagent' {
|
|
||||||
namespace request {
|
|
||||||
interface Request {
|
|
||||||
proxy(url: string): this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Proxy.setup(superagent);
|
|
||||||
|
|
||||||
export = superagent;
|
|
||||||
@@ -184,7 +184,7 @@ export async function create(
|
|||||||
mailLower: mail.trim().toLowerCase(),
|
mailLower: mail.trim().toLowerCase(),
|
||||||
uname,
|
uname,
|
||||||
unameLower: uname.trim().toLowerCase(),
|
unameLower: uname.trim().toLowerCase(),
|
||||||
hash: pwhash(password, salt),
|
hash: pwhash(password.toString(), salt),
|
||||||
salt,
|
salt,
|
||||||
hashType: 'hydro',
|
hashType: 'hydro',
|
||||||
regat: new Date(),
|
regat: new Date(),
|
||||||
@@ -195,6 +195,7 @@ export async function create(
|
|||||||
gravatar: mail,
|
gravatar: mail,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
throw new UserAlreadyExistError([uid, uname, mail]);
|
throw new UserAlreadyExistError([uid, uname, mail]);
|
||||||
}
|
}
|
||||||
return uid;
|
return uid;
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import 'hydrooj';
|
||||||
|
import md5 from 'hydrooj/src/lib/md5';
|
||||||
|
import sha1 from 'hydrooj/src/lib/sha1';
|
||||||
|
import pwhash from 'hydrooj/src/lib/hash.hydro';
|
||||||
|
import 'hydrooj/src/utils';
|
||||||
|
|
||||||
|
describe('crypto', () => {
|
||||||
|
const content1 = 'twd2akioi';
|
||||||
|
const content2 = '陈志鹏爱吃玻璃。';
|
||||||
|
|
||||||
|
test('MD5', () => {
|
||||||
|
const result1 = '57b6a9bd92c0502714ecedc4a5ebf24c';
|
||||||
|
const result2 = 'f598cb0738e7cd9efbbdf0ad7b6b42a7';
|
||||||
|
expect(md5(content1)).toStrictEqual(result1);
|
||||||
|
expect(md5(content2)).toStrictEqual(result2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('SHA1', () => {
|
||||||
|
const result1 = 'bade50df188c338fae183cf3bde34fafaf590bc5';
|
||||||
|
const result2 = '4d3fce39e3a163fe65263d8283ed3e98244fda42';
|
||||||
|
expect(sha1(content1)).toStrictEqual(result1);
|
||||||
|
expect(sha1(content2)).toStrictEqual(result2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('PWHASH', () => {
|
||||||
|
const password1 = 'password1';
|
||||||
|
const salt1 = '0326Bc23E6fac733K01g29fBBUSAj7O4';
|
||||||
|
const salt2 = String.random(32);
|
||||||
|
const hash1 = '70a2db6a53ecd75d8d4b19d8647a416b4e812c1a6635c4a1f5069a00382fdcb6';
|
||||||
|
expect(pwhash(password1, salt1)).toStrictEqual(hash1);
|
||||||
|
expect(pwhash(password1, salt2)).not.toEqual(hash1);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
import 'hydrooj';
|
|
||||||
import pwhash from 'hydrooj/src/lib/hash.hydro';
|
|
||||||
import 'hydrooj/src/utils';
|
|
||||||
|
|
||||||
describe('Hash', () => {
|
|
||||||
test('server', () => {
|
|
||||||
const password1 = 'password1';
|
|
||||||
const salt1 = '0326Bc23E6fac733K01g29fBBUSAj7O4';
|
|
||||||
const salt2 = String.random(32);
|
|
||||||
const hash1 = '70a2db6a53ecd75d8d4b19d8647a416b4e812c1a6635c4a1f5069a00382fdcb6';
|
|
||||||
expect(pwhash(password1, salt1)).toStrictEqual(hash1);
|
|
||||||
expect(pwhash(password1, salt2)).not.toEqual(hash1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hydrooj": "^2.12.1",
|
"hydrooj": "^2.12.1",
|
||||||
"superagent": "^5.3.1",
|
"superagent": "^6.0.0",
|
||||||
"superagent-proxy": "^2.0.0"
|
"superagent-proxy": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hydrooj": "^2.12.1",
|
"hydrooj": "^2.12.1",
|
||||||
"superagent": "^5.3.1",
|
"superagent": "^6.0.0",
|
||||||
"superagent-proxy": "^2.0.0"
|
"superagent-proxy": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hydrooj": "^2.12.1",
|
"hydrooj": "^2.12.1",
|
||||||
"superagent": "^5.3.1",
|
"superagent": "^6.0.0",
|
||||||
"superagent-proxy": "^2.0.0"
|
"superagent-proxy": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/migrate-vijos",
|
"name": "@hydrooj/migrate-vijos",
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "git@github.com:hydro-dev/Hydro.git",
|
"repository": "git@github.com:hydro-dev/Hydro.git",
|
||||||
"author": "undefined <masnn0@outlook.com>",
|
"author": "undefined <masnn0@outlook.com>",
|
||||||
|
|||||||
@@ -420,19 +420,19 @@ async function removeInvalidPid(src: Db, report: Function) {
|
|||||||
|
|
||||||
async function userfileUsage(src: Db, report: Function) {
|
async function userfileUsage(src: Db, report: Function) {
|
||||||
const count = await src.collection('domain.user').find().count();
|
const count = await src.collection('domain.user').find().count();
|
||||||
const bulk = dst.collection('user').initializeUnorderedBulkOp();
|
|
||||||
await report({ progress: 1, message: `userfileUsage: ${count}` });
|
await report({ progress: 1, message: `userfileUsage: ${count}` });
|
||||||
const total = Math.floor(count / 50);
|
const total = Math.floor(count / 50);
|
||||||
for (let i = 0; i <= total; i++) {
|
for (let i = 0; i <= total; i++) {
|
||||||
const docs = await src.collection('userfileUsage')
|
const docs = await src.collection('domain.user')
|
||||||
.find().skip(i * 50).limit(50)
|
.find().skip(i * 50).limit(50)
|
||||||
.toArray();
|
.toArray();
|
||||||
|
const t = [];
|
||||||
for (const doc of docs) {
|
for (const doc of docs) {
|
||||||
if (doc.userfile_usage) {
|
if (doc.userfile_usage) {
|
||||||
bulk.find({ _id: doc.uid }).updateOne({ $set: { usage: doc.userfile_usage } });
|
t.push(dst.collection('user').updateOne({ _id: doc.uid }, { $set: { usage: doc.userfile_usage } }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await bulk.execute();
|
await Promise.all(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user