mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
w: merge migration packages
This commit is contained in:
1 parent
b5e312b609
commit
74f4e44f0f
12 files changed
+27
-63
No files matched your search
@@ -1,12 +0,0 @@
|
|||||||
# migrate-hustoj
|
|
||||||
|
|
||||||
这个模块用于从HustOJ的数据库导入数据。
|
|
||||||
|
|
||||||
## 迁移须知
|
|
||||||
|
|
||||||
迁移前,您需要指定数据来源。
|
|
||||||
迁移过程中,Hydro 的内容会被**清空**,以下内容将被迁移:
|
|
||||||
|
|
||||||
题目与测试数据,用户列表。
|
|
||||||
|
|
||||||
迁移过程中请保持网络畅通。
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
migrate from hustoj: 从 HustOJ 导入
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { } from 'hydrooj';
|
|
||||||
|
|
||||||
const { md5, sha1 } = global.Hydro.lib;
|
|
||||||
|
|
||||||
interface Udoc {
|
|
||||||
uname: string,
|
|
||||||
unameLower: string,
|
|
||||||
}
|
|
||||||
|
|
||||||
function hash(password: string, salt: string, udoc: Udoc) {
|
|
||||||
const { uname, unameLower } = udoc;
|
|
||||||
const pmd5 = md5(password);
|
|
||||||
const mixedSha1 = sha1(md5(unameLower + pmd5) + salt + sha1(pmd5 + salt));
|
|
||||||
return `${Buffer.from(uname).toString('base64')}|${mixedSha1}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
global.Hydro.lib['hash.vj2'] = hash;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
migrate from vijos: 从 Vijos 导入
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@hydrooj/migrate-vijos",
|
|
||||||
"version": "1.5.1",
|
|
||||||
"main": "package.json",
|
|
||||||
"repository": "git@github.com:hydro-dev/Hydro.git",
|
|
||||||
"author": "undefined <i@undefined.moe>",
|
|
||||||
"preferUnplugged": true,
|
|
||||||
"license": "AGPL-3.0-or-later",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/mongodb": "^3.6.20"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"mongodb": "^3.7.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
# migrate-vijos
|
# migrate
|
||||||
|
|
||||||
这个模块用于从Vijos4.0的数据库导入数据。
|
|
||||||
|
|
||||||
## 迁移须知
|
这个模块用于从其他系统批量导入数据。
|
||||||
|
迁移过程中请保持网络畅通。
|
||||||
|
|
||||||
|
## migrate-vijos
|
||||||
|
|
||||||
|
从Vijos4.0的数据库导入数据。
|
||||||
迁移前,您需要指定数据来源。
|
迁移前,您需要指定数据来源。
|
||||||
**请不要**将 Hydro 正在使用的数据库设置为数据来源的数据库。
|
**请不要**将 Hydro 正在使用的数据库设置为数据来源的数据库。
|
||||||
迁移过程中,Hydro 的以下内容会被**清空**:
|
迁移过程中,Hydro 的以下内容会被**清空**:
|
||||||
|
|
||||||
题目列表,提交记录,用户列表,比赛列表,比赛成绩表,训练列表,训练进度,站内消息,题解,讨论
|
题目列表,提交记录,用户列表,比赛列表,比赛成绩表,训练列表,训练进度,站内消息,题解,讨论
|
||||||
|
|
||||||
以下内容将被迁移:
|
以下内容将被迁移:
|
||||||
|
|
||||||
题目与测试数据、题解,讨论与回复,比赛、训练、作业相关数据,提交记录,用户列表,站内消息。
|
题目与测试数据、题解,讨论与回复,比赛、训练、作业相关数据,提交记录,用户列表,站内消息。
|
||||||
|
|
||||||
迁移过程中请保持网络畅通。
|
## migrate-hustoj
|
||||||
|
|
||||||
|
从HustOJ的数据库导入数据。
|
||||||
|
迁移过程中,Hydro 的内容会被**清空**,以下内容将被迁移:
|
||||||
|
题目与测试数据,用户列表。
|
||||||
@@ -2,7 +2,7 @@ import { md5, sha1 } from 'hydrooj/src/lib/crypto';
|
|||||||
|
|
||||||
const RE_MD5 = /^[\da-f]{32}$/;
|
const RE_MD5 = /^[\da-f]{32}$/;
|
||||||
|
|
||||||
function hash($password: string, $saved: string) {
|
global.Hydro.lib['hash.hust'] = ($password: string, $saved: string) => {
|
||||||
$password = md5($password);
|
$password = md5($password);
|
||||||
if (RE_MD5.test($saved)) return $password === $saved;
|
if (RE_MD5.test($saved)) return $password === $saved;
|
||||||
const $svd = Buffer.from($saved, 'base64').toString('hex');
|
const $svd = Buffer.from($saved, 'base64').toString('hex');
|
||||||
@@ -13,6 +13,11 @@ function hash($password: string, $saved: string) {
|
|||||||
]).toString('base64');
|
]).toString('base64');
|
||||||
if ($hash.trim() === $saved.trim()) return true;
|
if ($hash.trim() === $saved.trim()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
};
|
||||||
|
|
||||||
global.Hydro.lib['hash.hust'] = hash;
|
global.Hydro.lib['hash.vj2'] = (password: string, salt: string, udoc: { uname: string; unameLower: string }) => {
|
||||||
|
const { uname, unameLower } = udoc;
|
||||||
|
const pmd5 = md5(password);
|
||||||
|
const mixedSha1 = sha1(md5(unameLower + pmd5) + salt + sha1(pmd5 + salt));
|
||||||
|
return `${Buffer.from(uname).toString('base64')}|${mixedSha1}`;
|
||||||
|
};
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
migrate from hustoj: 从 HustOJ 导入
|
||||||
|
migrate from vijos: 从 Vijos 导入
|
||||||
@@ -1,20 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/migrate-hustoj",
|
"name": "@hydrooj/migrate",
|
||||||
"version": "0.1.4",
|
"version": "0.1.0",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "git@github.com:hydro-dev/Hydro.git",
|
"repository": "git@github.com:hydro-dev/Hydro.git",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"preferUnplugged": true,
|
|
||||||
"scripts": {
|
|
||||||
"lint": "eslint lib.ts script.ts --fix",
|
|
||||||
"build": "tsc"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/mongodb": "^3.6.20",
|
||||||
"@types/mysql": "^2.15.21"
|
"@types/mysql": "^2.15.21"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hydrooj/utils": "workspace:*",
|
"@hydrooj/utils": "workspace:*",
|
||||||
|
"mongodb": "^3.7.3",
|
||||||
"mysql": "^2.18.1"
|
"mysql": "^2.18.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
import './scripts/hustoj';
|
||||||
|
import './scripts/vijos';
|
||||||
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user