From f183f122e926b6a496b70d718f9830cfdd3e4f02 Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Fri, 23 Feb 2024 12:11:03 -0500 Subject: [PATCH] bug fix --- lib/api/controllers/migration/exportData.ts | 2 + .../migration/importFromLinkwarden.ts | 41 +++++-------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/lib/api/controllers/migration/exportData.ts b/lib/api/controllers/migration/exportData.ts index 2776d85..73141fd 100644 --- a/lib/api/controllers/migration/exportData.ts +++ b/lib/api/controllers/migration/exportData.ts @@ -13,6 +13,8 @@ export default async function exportData(userId: number) { }, }, }, + pinnedLinks: true, + whitelistedUsers: true, }, }); diff --git a/lib/api/controllers/migration/importFromLinkwarden.ts b/lib/api/controllers/migration/importFromLinkwarden.ts index 51f8ecf..3f91f19 100644 --- a/lib/api/controllers/migration/importFromLinkwarden.ts +++ b/lib/api/controllers/migration/importFromLinkwarden.ts @@ -37,41 +37,20 @@ export default async function importFromLinkwarden( for (const e of data.collections) { e.name = e.name.trim(); - const findCollection = await prisma.user.findUnique({ - where: { - id: userId, - }, - select: { - collections: { - where: { - name: e.name, + const newCollection = await prisma.collection.create({ + data: { + owner: { + connect: { + id: userId, }, }, + name: e.name, + description: e.description, + color: e.color, }, }); - const checkIfCollectionExists = findCollection?.collections[0]; - - let collectionId = findCollection?.collections[0]?.id; - - if (!checkIfCollectionExists) { - const newCollection = await prisma.collection.create({ - data: { - owner: { - connect: { - id: userId, - }, - }, - name: e.name, - description: e.description, - color: e.color, - }, - }); - - createFolder({ filePath: `archives/${newCollection.id}` }); - - collectionId = newCollection.id; - } + createFolder({ filePath: `archives/${newCollection.id}` }); // Import Links for (const link of e.links) { @@ -82,7 +61,7 @@ export default async function importFromLinkwarden( description: link.description, collection: { connect: { - id: collectionId, + id: newCollection.id, }, }, // Import Tags