Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/actions/provider-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,15 @@ export async function removeProviderEndpoint(input: unknown): Promise<ActionResu
}

// Auto cleanup: if the vendor has no active providers/endpoints, delete it as well.
await tryDeleteProviderVendorIfEmpty(endpoint.vendorId);
try {
await tryDeleteProviderVendorIfEmpty(endpoint.vendorId);
} catch (error) {
logger.warn("removeProviderEndpoint:vendor_cleanup_failed", {
endpointId: parsed.data.endpointId,
vendorId: endpoint.vendorId,
error: error instanceof Error ? error.message : String(error),
});
}

return { ok: true };
} catch (error) {
Expand Down
30 changes: 24 additions & 6 deletions src/actions/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,15 @@ export async function removeProvider(providerId: number): Promise<ActionResult>

// Auto cleanup: delete vendor if it has no active providers/endpoints.
if (provider?.providerVendorId) {
await tryDeleteProviderVendorIfEmpty(provider.providerVendorId);
try {
await tryDeleteProviderVendorIfEmpty(provider.providerVendorId);
} catch (error) {
logger.warn("removeProvider:vendor_cleanup_failed", {
providerId,
vendorId: provider.providerVendorId,
error: error instanceof Error ? error.message : String(error),
});
}
}

// 广播缓存更新(跨实例即时生效)
Expand Down Expand Up @@ -3713,10 +3721,13 @@ export async function reclusterProviderVendors(args: {
if (!provider) continue;

// Get or create new vendor
const newVendorId = await getOrCreateProviderVendorIdFromUrls({
providerUrl: provider.url,
websiteUrl: provider.websiteUrl ?? null,
});
const newVendorId = await getOrCreateProviderVendorIdFromUrls(
{
providerUrl: provider.url,
websiteUrl: provider.websiteUrl ?? null,
},
{ tx }
);

// Update provider's vendorId
await tx
Expand All @@ -3731,7 +3742,14 @@ export async function reclusterProviderVendors(args: {

// Cleanup empty vendors
for (const oldVendorId of oldVendorIds) {
await tryDeleteProviderVendorIfEmpty(oldVendorId);
try {
await tryDeleteProviderVendorIfEmpty(oldVendorId);
} catch (error) {
logger.warn("reclusterProviderVendors:vendor_cleanup_failed", {
vendorId: oldVendorId,
error: error instanceof Error ? error.message : String(error),
});
}
}

// Publish cache invalidation
Expand Down
Loading
Loading