fix
This commit is contained in:
@@ -208,7 +208,7 @@ app
|
||||
try {
|
||||
const _user = await User.getUserByToken(ctx.query.token);
|
||||
if (_user.hasUser(username)) {
|
||||
const upUser = await User.findOne({ where: { username } });
|
||||
const upUser = await User.findOne({ username });
|
||||
uid = upUser.id;
|
||||
userPrefix = username;
|
||||
}
|
||||
@@ -318,6 +318,7 @@ app
|
||||
if (!appList) {
|
||||
ctx.throw('app 未发现');
|
||||
}
|
||||
let isDetect = false;
|
||||
if (detect) {
|
||||
const appKey = appList.key;
|
||||
const version = appList.version;
|
||||
@@ -328,11 +329,11 @@ app
|
||||
}
|
||||
const appLists2 = await db.select().from(schema.kvAppList).where(eq(schema.kvAppList.id, appList.id)).limit(1);
|
||||
appList = appLists2[0];
|
||||
isDetect = true;
|
||||
}
|
||||
if (!appList) {
|
||||
ctx.throw('app 未发现');
|
||||
}
|
||||
|
||||
const appListData = appList.data as AppData;
|
||||
const files = appListData.files || [];
|
||||
const ams = await db.select().from(schema.kvApp).where(and(
|
||||
@@ -343,10 +344,13 @@ app
|
||||
if (!am) {
|
||||
ctx.throw('app 未发现');
|
||||
}
|
||||
if (!isDetect) {
|
||||
const amData = am.data as AppData;
|
||||
await db.update(schema.kvApp)
|
||||
.set({ data: { ...amData, files }, version: appList.version, updatedAt: new Date().toISOString() })
|
||||
.where(eq(schema.kvApp.id, am.id));
|
||||
}
|
||||
|
||||
setExpire(appList.key, am.user);
|
||||
ctx.body = {
|
||||
key: appList.key,
|
||||
@@ -465,14 +469,13 @@ app
|
||||
let am = ams[0];
|
||||
if (!am) {
|
||||
const newAms = await db.insert(schema.kvApp).values({
|
||||
id: randomUUID(),
|
||||
title: appKey,
|
||||
key: appKey,
|
||||
version: version || '0.0.1',
|
||||
user: checkUsername,
|
||||
uid,
|
||||
data: { files: needAddFiles },
|
||||
proxy: appKey.includes('center') ? false : true,
|
||||
proxy: true,
|
||||
}).returning();
|
||||
am = newAms[0];
|
||||
} else {
|
||||
@@ -483,8 +486,9 @@ app
|
||||
)).limit(1);
|
||||
const appModel = appModels[0];
|
||||
if (appModel) {
|
||||
const data = appModel.data as AppData;
|
||||
await db.update(schema.kvApp)
|
||||
.set({ data: { files: needAddFiles }, updatedAt: new Date().toISOString() })
|
||||
.set({ data: { ...data, files: needAddFiles }, updatedAt: new Date().toISOString() })
|
||||
.where(eq(schema.kvApp.id, appModel.id));
|
||||
setExpire(appModel.key, appModel.user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user