feat: add s1/resources/upload
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user