Rename for clarity

This commit is contained in:
Owen
2026-06-24 18:35:42 -04:00
parent 79de64dc07
commit be3877a3ce

View File

@@ -35,6 +35,7 @@ import {
parseEndpoint parseEndpoint
} from "@server/lib/ip"; } from "@server/lib/ip";
import { import {
addPeerData,
addPeerDataBatch, addPeerDataBatch,
addTargetsBatch as addSubnetProxyTargetsBatch, addTargetsBatch as addSubnetProxyTargetsBatch,
removePeerDataBatch, removePeerDataBatch,
@@ -1258,6 +1259,7 @@ export async function handleMessagingForUpdatedSiteResource(
`handleMessagingForUpdatedSiteResource: checking old destination reuse destination=${existingSiteResource.destination} across siteCount=${allSiteIds.length} clientCount=${mergedAllClients.length}` `handleMessagingForUpdatedSiteResource: checking old destination reuse destination=${existingSiteResource.destination} across siteCount=${allSiteIds.length} clientCount=${mergedAllClients.length}`
); );
// we need to do this because the client only knows about peers not resources so we need to make sure that we dont remove it if there is still a another resource
const oldDestinationStillInUseRows = await trx const oldDestinationStillInUseRows = await trx
.select({ .select({
clientId: clientSiteResourcesAssociationsCache.clientId, clientId: clientSiteResourcesAssociationsCache.clientId,
@@ -1348,20 +1350,23 @@ export async function handleMessagingForUpdatedSiteResource(
version: newt.version version: newt.version
}); });
for (const client of mergedAllClients) { for (const client of mergedAllClients) {
const oldDestinationStillInUseByASite = // we need to do this because the client only knows about peers not resources so we need to make sure that we dont remove it if there is still a another resource
const oldDestinationStillInUseBySite =
oldDestinationStillInUseClientSitePairs.has( oldDestinationStillInUseClientSitePairs.has(
`${client.clientId}:${siteId}` `${client.clientId}:${siteId}`
); );
peerDataRemoves.push({ if (existingSiteResource) {
// this might happen twice after the rebuild function but that is okay peerDataRemoves.push({
clientId: client.clientId, // this might happen twice after the rebuild function but that is okay
siteId, clientId: client.clientId,
remoteSubnets: !oldDestinationStillInUseByASite siteId,
? generateRemoteSubnets([updatedSiteResource]) remoteSubnets: !oldDestinationStillInUseBySite
: [], ? generateRemoteSubnets([existingSiteResource])
aliases: generateAliasConfig([updatedSiteResource]) : [],
}); aliases: generateAliasConfig([existingSiteResource])
});
}
} }
} }
} else { } else {
@@ -1577,7 +1582,8 @@ export async function handleMessagingForUpdatedSiteResource(
continue; continue;
} }
const oldDestinationStillInUseByASite = // we need to do this because the client only knows about peers not resources so we need to make sure that we dont remove it if there is still a another resource
const oldDestinationStillInUseBySite =
oldDestinationStillInUseClientSitePairs.has( oldDestinationStillInUseClientSitePairs.has(
`${client.clientId}:${siteId}` `${client.clientId}:${siteId}`
); );
@@ -1588,7 +1594,7 @@ export async function handleMessagingForUpdatedSiteResource(
siteId, siteId,
remoteSubnets: destinationChanged remoteSubnets: destinationChanged
? { ? {
oldRemoteSubnets: !oldDestinationStillInUseByASite oldRemoteSubnets: !oldDestinationStillInUseBySite
? generateRemoteSubnets([ ? generateRemoteSubnets([
existingSiteResource existingSiteResource
]) ])
@@ -2363,7 +2369,7 @@ async function handleMessagesForClientResources(
) )
); );
// Only remove remote subnet if no other resource uses the same destination // Only remove remote subnet if no other resource uses the same destination on the same site
const remoteSubnetsToRemove = const remoteSubnetsToRemove =
destinationStillInUse.length > 0 destinationStillInUse.length > 0
? [] ? []