mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: add fixSorage
This commit is contained in:
7 files changed
+88
-22
No files matched your search
@@ -111,7 +111,9 @@ Hydro 用户群:1085853538
|
||||
<details>
|
||||
<summary><h2>更新日志(点击展开)</h2></summary>
|
||||
|
||||
## Hydro 5.0.0-beta.0 / UI 4.58.0-beta.0
|
||||
## Hydro 5.0.0-beta.3 / UI 4.58.0-beta.3
|
||||
|
||||
### New Features
|
||||
|
||||
- judge: 添加 checker 编译缓存
|
||||
- ui: 优化题目详情页面 OGP 信息
|
||||
@@ -127,21 +129,32 @@ Hydro 用户群:1085853538
|
||||
- core: 分离 HMR 和 Watcher 组件
|
||||
- core: i18n: 添加 interface 选项
|
||||
- judge: 添加 kattis checker 支持
|
||||
- migrate: 修复 hustoj 自动运行
|
||||
- core: Settings: 支持使用 Schemastery
|
||||
- ui: 更新系统设置页面样式
|
||||
- import-qduoj: 修复 spj=null
|
||||
- core: 修复文件复制
|
||||
- core: 支持存储并显示提交记录重测历史
|
||||
- core: 新的加域逻辑
|
||||
- ui: UserSelect.Multi: 支持批量粘贴用户名
|
||||
- ui: 修复在线 IDE 右键菜单
|
||||
- ui: 修复未登录用户查看题目文件页
|
||||
- core: oauth: 支持绑定/解绑三方平台账户 (#971)
|
||||
- ui: 修复暗色模式表格边框 (#968)
|
||||
- core: 优化 icpc 题目包导入 (#966)
|
||||
- judge: 弃用 diff (#965)
|
||||
- core: 支持设置加域时自动加入小组
|
||||
- core: 添加 `--disable-worker` 启动选项
|
||||
- ui: 支持使用自定义字体
|
||||
- framework: 添加 Subscription API
|
||||
- core: 添加 fixStorage 脚本
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- migrate: 修复 hustoj 自动运行
|
||||
- import-qduoj: 修复 spj=null
|
||||
- core: 修复文件复制
|
||||
- ui: 修复在线 IDE 右键菜单
|
||||
- ui: 修复未登录用户查看题目文件页
|
||||
- ui: 修复暗色模式表格边框 (#968)
|
||||
- ui: 修复题解回复编辑权限
|
||||
- ui: 修复高亮行号显示
|
||||
- core: 修复 `User.serialize()` 参数
|
||||
- ui: 修复更换邮箱功能
|
||||
|
||||
### Breaking API Changes
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
"license": "MIT",
|
||||
"main": "base.mjs",
|
||||
"dependencies": {
|
||||
"@eslint-react/eslint-plugin": "^1.51.0",
|
||||
"@eslint-react/eslint-plugin": "^1.51.2",
|
||||
"@eslint/compat": "^1.2.9",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@stylistic/eslint-plugin": "^4.4.0",
|
||||
"@stylistic/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
||||
"@typescript-eslint/parser": "^8.33.1",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-plugin-de-morgan": "^1.2.1",
|
||||
"eslint-plugin-de-morgan": "^1.3.0",
|
||||
"eslint-plugin-github": "^6.0.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@
|
||||
"cross-spawn": "^7.0.6",
|
||||
"esbuild": "0.25.2",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-import-resolver-typescript": "^4.4.2",
|
||||
"eslint-import-resolver-typescript": "^4.4.3",
|
||||
"eslint-import-resolver-webpack": "^0.13.10",
|
||||
"fs-extra": "^11.3.0",
|
||||
"globals": "^16.2.0",
|
||||
@@ -56,7 +56,7 @@
|
||||
"oxlint": "^0.16.12",
|
||||
"package-json": "^10.0.1",
|
||||
"semver": "^7.7.2",
|
||||
"simple-git": "^3.27.0",
|
||||
"simple-git": "^3.28.0",
|
||||
"supertest": "^7.1.1",
|
||||
"supports-hyperlinks": "^4.1.0",
|
||||
"typescript": "5.8.3",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"react-dnd": "^16.0.1",
|
||||
"react-dnd-html5-backend": "^16.0.1",
|
||||
"react-toastify": "^11.0.5",
|
||||
"schemastery-react": "^0.1.2"
|
||||
"schemastery-react": "^0.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/diff": "^8.0.0",
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import { resolve } from 'path';
|
||||
import {
|
||||
existsSync, mkdir, readdir, rename, rmdir,
|
||||
} from 'fs-extra';
|
||||
import Schema from 'schemastery';
|
||||
import { Context } from '../context';
|
||||
|
||||
export const apply = (ctx: Context) => ctx.addScript(
|
||||
'fixStorage', 'Rename all files to lowercase',
|
||||
Schema.object({}),
|
||||
async () => {
|
||||
const config = await ctx.get('storage').status();
|
||||
console.log(config);
|
||||
if (config.type !== 'Local') throw new Error('Only local storage is supported');
|
||||
const dir = (config as any).dir;
|
||||
if (!dir) throw new Error('Storage dir not found');
|
||||
const files = await readdir(dir);
|
||||
for (const file of files) {
|
||||
let inner = await readdir(resolve(dir, file));
|
||||
if (file.toLowerCase() !== file && !existsSync(resolve(dir, file.toLowerCase()))) {
|
||||
await mkdir(resolve(dir, file.toLowerCase()));
|
||||
console.log('+: ', resolve(dir, file.toLowerCase()));
|
||||
}
|
||||
for (const f of inner) {
|
||||
if (resolve(dir, file, f) === resolve(dir, file.toLowerCase(), f.toLowerCase())) continue;
|
||||
await rename(resolve(dir, file, f), resolve(dir, file.toLowerCase(), f.toLowerCase()));
|
||||
console.log('R: ', resolve(dir, file, f), '->', resolve(dir, file.toLowerCase(), f.toLowerCase()));
|
||||
}
|
||||
inner = await readdir(resolve(dir, file));
|
||||
if (!inner.length) {
|
||||
await rmdir(resolve(dir, file));
|
||||
console.log('-: ', resolve(dir, file));
|
||||
}
|
||||
}
|
||||
const coll = ctx.get('db').collection('storage');
|
||||
while (true) {
|
||||
let hasItem = false;
|
||||
for await (const t of coll.find({ $or: [{ _id: /[A-Z]/ }, { link: /[A-Z]/ }] })) {
|
||||
hasItem = true;
|
||||
await coll.insertOne({
|
||||
...t,
|
||||
_id: t._id.toLowerCase(),
|
||||
...(t.link ? { link: t.link.toLowerCase() } : {}),
|
||||
});
|
||||
await coll.deleteOne({ _id: t._id });
|
||||
console.log('Q: ', t._id, '->', t._id.toLowerCase());
|
||||
}
|
||||
if (!hasItem) break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
);
|
||||
@@ -387,6 +387,7 @@ class LocalStorageService {
|
||||
status: !this.error,
|
||||
error: this.error,
|
||||
bucket: 'Hydro',
|
||||
dir: this.config.path,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,16 +12,16 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blueprintjs/core": "^5.19.0",
|
||||
"@fontsource/dm-mono": "^5.2.5",
|
||||
"@fontsource/dm-mono": "^5.2.6",
|
||||
"@fontsource/fira-code": "^5.2.6",
|
||||
"@fontsource/inconsolata": "^5.2.5",
|
||||
"@fontsource/jetbrains-mono": "^5.2.5",
|
||||
"@fontsource/pt-mono": "^5.2.5",
|
||||
"@fontsource/inconsolata": "^5.2.6",
|
||||
"@fontsource/jetbrains-mono": "^5.2.6",
|
||||
"@fontsource/pt-mono": "^5.2.6",
|
||||
"@fontsource/roboto-mono": "^5.2.6",
|
||||
"@fontsource/source-code-pro": "^5.2.6",
|
||||
"@fontsource/ubuntu-mono": "^5.2.5",
|
||||
"@fontsource/ubuntu-mono": "^5.2.6",
|
||||
"@hydrooj/utils": "workspace:^",
|
||||
"@sentry/browser": "^9.25.1",
|
||||
"@sentry/browser": "^9.27.0",
|
||||
"@sentry/webpack-plugin": "^3.5.0",
|
||||
"@simplewebauthn/browser": "13.1.0",
|
||||
"@svgr/webpack": "^8.1.0",
|
||||
@@ -50,8 +50,8 @@
|
||||
"clipboard": "^2.0.11",
|
||||
"copy-webpack-plugin": "^13.0.0",
|
||||
"cordis": "4.0.0-beta.5",
|
||||
"core-js": "^3.42.0",
|
||||
"core-js-compat": "^3.42.0",
|
||||
"core-js": "^3.43.0",
|
||||
"core-js-compat": "^3.43.0",
|
||||
"css-loader": "^7.1.2",
|
||||
"diff": "^8.0.2",
|
||||
"diff-dom": "^5.2.0",
|
||||
@@ -101,7 +101,6 @@
|
||||
"sass": "^1.89.1",
|
||||
"sass-loader": "^16.0.5",
|
||||
"schemastery": "^3.16.1",
|
||||
"schemastery-react": "^0.1.2",
|
||||
"shorty.js": "^1.0.1",
|
||||
"slideout": "^1.0.1",
|
||||
"sticky-kit": "^1.1.3",
|
||||
|
||||
Reference in new issue
Block a user