fix: project with null remoteId don't need to be updated (#7464)

* fix: project with null remoteId don't need to be updated

* fix: add detailed comments
This commit is contained in:
Curry Yang
2024-05-29 17:30:43 +08:00
committed by GitHub
parent 55440c77ae
commit 41c79a13b4

View File

@@ -186,8 +186,13 @@ async function syncTeamProjects({
const removedRemoteProjects = await database.find<Project>(models.project.type, {
// filter by this organization so no legacy data can be accidentally removed, because legacy had null parentId
parentId: organizationId,
// Remote ID is not in the list of remote projects
remoteId: { $nin: teamProjects.map(p => p.id) },
// Remote ID is not in the list of remote projects.
// add `$ne: null` condition because if remoteId is already null, we dont need to remove it again.
// nedb use append-only format, all updates and deletes actually result in lines added
remoteId: {
$nin: teamProjects.map(p => p.id),
$ne: null,
},
});
await Promise.all(removedRemoteProjects.map(async prj => {