From f23eb9f4ad85bde2d4afe2152807597db50ab24e Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Jan 2023 18:28:09 +0100 Subject: [PATCH] refs #4975 Added call to last method in upload --- modules/mdb/back/methods/mdbVersion/upload.js | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js index 8c77281b15..fa196b58d9 100644 --- a/modules/mdb/back/methods/mdbVersion/upload.js +++ b/modules/mdb/back/methods/mdbVersion/upload.js @@ -63,22 +63,13 @@ module.exports = Self => { if (!existBranch) throw new UserError('Not exist this branch'); - let lastVersion = await models.MdbBranch.findOne({ - where: {appName} - }, myOptions); + let lastMethod = await Self.last(ctx, appName, myOptions); + lastMethod.version++; - if (lastVersion++ != toVersion) + if (lastMethod.version != toVersion) throw new UserError('Try again'); const userId = ctx.req.accessToken.userId; - models.MdbVersionTree.create({ - app: appName, - version: toVersion, - branchFk: branch, - fromVersion, - userFk: userId - }); - const tempContainer = await TempContainer.container('access'); const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions); const files = Object.values(uploaded.files).map(file => { @@ -121,6 +112,14 @@ module.exports = Self => { } } + await models.MdbVersionTree.create({ + app: appName, + version: toVersion, + branchFk: branch, + fromVersion, + userFk: userId + }, myOptions); + await models.MdbVersion.upsert({ app: appName, branchFk: branch,