feat: add s1/resources/upload

This commit is contained in:
2025-03-15 11:38:57 +08:00
parent d947043a16
commit 9b1045d456
4 changed files with 154 additions and 3 deletions

View File

@@ -167,21 +167,23 @@ app
}
}
let am = await AppModel.findOne({ where: { key: appKey, uid } });
let appIsNew = false;
if (!am) {
appIsNew = true;
am = await AppModel.create({
user: userPrefix,
key: appKey,
uid,
version: '0.0.0',
version: version || '0.0.0',
title: appKey,
proxy: true,
data: {
files: [],
files: files || [],
},
});
}
let app = await AppListModel.findOne({ where: { version: version, key: appKey, uid: uid } });
if (!app) {
// throw new CustomError('app not found');
app = await AppListModel.create({
key: appKey,
version,
@@ -194,6 +196,9 @@ app
const dataFiles = app.data.files || [];
const newFiles = _.uniqBy([...dataFiles, ...files], 'name');
const res = await app.update({ data: { ...app.data, files: newFiles } });
if (version === am.version && !appIsNew) {
await am.update({ data: { ...am.data, files: newFiles } });
}
setExpire(app.id, 'test');
ctx.body = prefixFix(res, userPrefix);
} catch (e) {