chore: Refactor collection export to match import (#3483)

* chore: Refactor collection export to use FileOperations processor and task

* Tweak options
This commit is contained in:
Tom Moor
2022-05-01 21:06:07 -07:00
committed by GitHub
parent 669575fc89
commit eeb8008927
9 changed files with 210 additions and 181 deletions

View File

@@ -495,11 +495,14 @@ router.post("collections.export", auth(), async (ctx) => {
}).findByPk(id);
authorize(user, "read", collection);
const fileOperation = await collectionExporter({
collection,
user,
team,
ip: ctx.request.ip,
const fileOperation = await sequelize.transaction(async (transaction) => {
return collectionExporter({
collection,
user,
team,
ip: ctx.request.ip,
transaction,
});
});
ctx.body = {
@@ -515,10 +518,13 @@ router.post("collections.export_all", auth(), async (ctx) => {
const team = await Team.findByPk(user.teamId);
authorize(user, "export", team);
const fileOperation = await collectionExporter({
user,
team,
ip: ctx.request.ip,
const fileOperation = await sequelize.transaction(async (transaction) => {
return collectionExporter({
user,
team,
ip: ctx.request.ip,
transaction,
});
});
ctx.body = {