mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-25 18:30:18 -06:00
Merge pull request #1903 from NguyenTranHoangSym/SDA-4182_racing
SDA-4182_racing: Add racing condition
This commit is contained in:
commit
f8ac374c54
@ -12,24 +12,22 @@ export const retrieveWindowsRegistry = async (): Promise<string> => {
|
||||
const Registry = require('winreg');
|
||||
const registryLocalStore = RegistryStore;
|
||||
const fetchLogic = (err, channel) => {
|
||||
if (err) {
|
||||
logger.info('registry-handler: error occurred. Details: ', err);
|
||||
if (err || !channel) {
|
||||
logger.error('registry-handler: error occurred. Details: ', err);
|
||||
|
||||
return 'An error has occurred';
|
||||
return '';
|
||||
} else {
|
||||
if (channel.type === RegistryValueType.REG_SZ) {
|
||||
if (channel?.type === RegistryValueType.REG_SZ) {
|
||||
registryLocalStore.setRegistry({ currentChannel: channel.value });
|
||||
logger.info(
|
||||
'registry-handler: value retrieved successfully, send to Registry Store',
|
||||
);
|
||||
|
||||
return channel.value;
|
||||
} else {
|
||||
logger.info(
|
||||
'registry-handler: the value was looked for did not exist or its VALUE_TYPE is incorrect',
|
||||
);
|
||||
|
||||
return 'Key Value doesnt exist';
|
||||
return '';
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -44,18 +42,21 @@ export const retrieveWindowsRegistry = async (): Promise<string> => {
|
||||
key: CHANNEL_NEST_LOCATION,
|
||||
});
|
||||
|
||||
return regKeyUser.get(CHANNEL_KEY, (error, channel) => {
|
||||
if (error && !channel) {
|
||||
regKeyLocal.get(CHANNEL_KEY, (err, localChannel) => {
|
||||
return fetchLogic(err, localChannel);
|
||||
});
|
||||
} else if (channel.type === RegistryValueType.REG_SZ) {
|
||||
registryLocalStore.setRegistry({ currentChannel: channel.value });
|
||||
logger.info(
|
||||
'registry-handler: value retrieved successfully, send to Registry Store',
|
||||
);
|
||||
return new Promise((resolve) => {
|
||||
regKeyUser.get(CHANNEL_KEY, (error, channel) => {
|
||||
if (error || !channel) {
|
||||
logger.error('registry-handler: error occurred. Details: ', error);
|
||||
|
||||
return channel;
|
||||
}
|
||||
regKeyLocal.get(CHANNEL_KEY, (err, localChannel) => {
|
||||
resolve(fetchLogic(err, localChannel));
|
||||
});
|
||||
} else if (channel.type === RegistryValueType.REG_SZ) {
|
||||
logger.info(
|
||||
'registry-handler: value retrieved successfully, send to Registry Store',
|
||||
);
|
||||
registryLocalStore.setRegistry({ currentChannel: channel.value });
|
||||
resolve(channel.value);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user