make sure we remove items when updating a file in the db (#8551)

This commit is contained in:
James Gatz
2025-03-31 13:20:15 +02:00
committed by Jay Wu
parent 7799ab6ca5
commit 70cbfeec9c

View File

@@ -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 });