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