From 70cbfeec9c59fb86f36af8aefce851eabb698224 Mon Sep 17 00:00:00 2001 From: James Gatz Date: Mon, 31 Mar 2025 13:20:15 +0200 Subject: [PATCH] make sure we remove items when updating a file in the db (#8551) --- packages/insomnia/src/sync/git/project-ne-db-client.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/insomnia/src/sync/git/project-ne-db-client.ts b/packages/insomnia/src/sync/git/project-ne-db-client.ts index c46eda5ae7..285ffacae9 100644 --- a/packages/insomnia/src/sync/git/project-ne-db-client.ts +++ b/packages/insomnia/src/sync/git/project-ne-db-client.ts @@ -89,6 +89,12 @@ export class GitProjectNeDBClient { const bufferId = await db.bufferChanges(); + const workspace = dataToImport.find(isWorkspace) as Workspace | undefined; + + const isExistingWorkspace = workspace && await models.workspace.getById(workspace._id); + // Remove the workspace if it already exists to clean up any descendants that might have been removed. + isExistingWorkspace && await models.workspace.remove(workspace); + for (const doc of dataToImport) { if (isWorkspace(doc)) { console.log('[git] setting workspace parent to be that of the active project', { original: doc.parentId, new: this._projectId });