mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-04-07 18:03:17 +08:00
fix: 修复文件和模块命名/重复添加的逻辑
This commit is contained in:
@@ -18,14 +18,17 @@ export default function register($app) {
|
||||
// file API
|
||||
function createFile(req, res) {
|
||||
const file = req.body;
|
||||
file.name = `${file.name ?? Date.now()}`;
|
||||
$.info(`正在创建文件:${file.name}`);
|
||||
const allFiles = $.read(FILES_KEY);
|
||||
if (findByName(allFiles, file.name)) {
|
||||
failed(
|
||||
return failed(
|
||||
res,
|
||||
new RequestInvalidError(
|
||||
'DUPLICATE_KEY',
|
||||
`File ${file.name} already exists.`,
|
||||
req.body.name
|
||||
? `已存在 name 为 ${file.name} 的文件`
|
||||
: `无法同时创建相同的文件 可稍后重试`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user