1
0
Fork 1
mirror of https://example.com synced 2024-11-23 09:26:40 +09:00

fix: 🐛 unlock undefined

This commit is contained in:
ThatOneCalculator 2023-09-01 19:19:42 -07:00
parent 4ed0b60621
commit 805230341e
No known key found for this signature in database
GPG key ID: 8703CACD01000000

View file

@ -15,8 +15,6 @@ export async function fetchInstanceMetadata(
instance: Instance, instance: Instance,
force = false, force = false,
): Promise<void> { ): Promise<void> {
const unlock = await getFetchInstanceMetadataLock(instance.host);
if (!force) { if (!force) {
const _instance = await Instances.findOneBy({ host: instance.host }); const _instance = await Instances.findOneBy({ host: instance.host });
const now = Date.now(); const now = Date.now();
@ -24,7 +22,7 @@ export async function fetchInstanceMetadata(
_instance?.infoUpdatedAt && _instance?.infoUpdatedAt &&
now - _instance.infoUpdatedAt.getTime() < 1000 * 60 * 60 * 24 now - _instance.infoUpdatedAt.getTime() < 1000 * 60 * 60 * 24
) { ) {
unlock(); await getFetchInstanceMetadataLock(instance.host);
return; return;
} }
} }
@ -53,7 +51,7 @@ export async function fetchInstanceMetadata(
} as Record<string, any>; } as Record<string, any>;
if (info) { if (info) {
updates.softwareName = info.software?.name.toLowerCase(); updates.softwareName = info.software?.name?.toLowerCase() || null;
updates.softwareVersion = info.software?.version; updates.softwareVersion = info.software?.version;
updates.openRegistrations = info.openRegistrations; updates.openRegistrations = info.openRegistrations;
updates.maintainerName = info.metadata updates.maintainerName = info.metadata
@ -80,24 +78,24 @@ export async function fetchInstanceMetadata(
} catch (e) { } catch (e) {
logger.error(`Failed to update metadata of ${instance.host}: ${e}`); logger.error(`Failed to update metadata of ${instance.host}: ${e}`);
} finally { } finally {
unlock(); await getFetchInstanceMetadataLock(instance.host)
} }
} }
type NodeInfo = { type NodeInfo = {
openRegistrations?: any; openRegistrations?: boolean;
software?: { software?: {
name?: any; name?: string;
version?: any; version?: string;
}; };
metadata?: { metadata?: {
name?: any; name?: string;
nodeName?: any; nodeName?: string;
nodeDescription?: any; nodeDescription?: string;
description?: any; description?: string;
maintainer?: { maintainer?: {
name?: any; name?: string;
email?: any; email?: string;
}; };
}; };
}; };