mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Avoid racing reads from storage that could cause pairing data to be wiped
This commit is contained in:
parent
6c457fe56d
commit
ddd7310e38
@ -185,8 +185,16 @@ function updateBitrateField() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moduleDidLoad() {
|
function moduleDidLoad() {
|
||||||
if(!myUniqueid) {
|
// load the HTTP cert and unique ID if we have one.
|
||||||
console.warn('%c[index.js, moduleDidLoad]', 'color: green;', 'Failed to get uniqueId. We should have already generated one. Regenerating...');
|
chrome.storage.sync.get('cert', function(savedCert) {
|
||||||
|
if (savedCert.cert != null) { // we have a saved cert
|
||||||
|
pairingCert = savedCert.cert;
|
||||||
|
}
|
||||||
|
|
||||||
|
chrome.storage.sync.get('uniqueid', function(savedUniqueid) {
|
||||||
|
if (savedUniqueid.uniqueid != null) { // we have a saved uniqueid
|
||||||
|
myUniqueid = savedUniqueid.uniqueid;
|
||||||
|
} else {
|
||||||
myUniqueid = uniqueid();
|
myUniqueid = uniqueid();
|
||||||
storeData('uniqueid', myUniqueid, null);
|
storeData('uniqueid', myUniqueid, null);
|
||||||
}
|
}
|
||||||
@ -214,6 +222,8 @@ function moduleDidLoad() {
|
|||||||
console.error('%c[index.js, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit);
|
console.error('%c[index.js, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// pair to the given NvHTTP host object. Returns whether pairing was successful.
|
// pair to the given NvHTTP host object. Returns whether pairing was successful.
|
||||||
@ -870,22 +880,6 @@ function onWindowLoad(){
|
|||||||
updateBitrateField();
|
updateBitrateField();
|
||||||
});
|
});
|
||||||
|
|
||||||
// load the HTTP cert if we have one.
|
|
||||||
chrome.storage.sync.get('cert', function(savedCert) {
|
|
||||||
if (savedCert.cert != null) { // we have a saved cert
|
|
||||||
pairingCert = savedCert.cert;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.storage.sync.get('uniqueid', function(savedUniqueid) {
|
|
||||||
if (savedUniqueid.uniqueid != null) { // we have a saved uniqueid
|
|
||||||
myUniqueid = savedUniqueid.uniqueid;
|
|
||||||
} else {
|
|
||||||
myUniqueid = uniqueid();
|
|
||||||
storeData('uniqueid', myUniqueid, null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// load previously connected hosts, which have been killed into an object, and revive them back into a class
|
// load previously connected hosts, which have been killed into an object, and revive them back into a class
|
||||||
chrome.storage.sync.get('hosts', function(previousValue) {
|
chrome.storage.sync.get('hosts', function(previousValue) {
|
||||||
hosts = previousValue.hosts != null ? previousValue.hosts : {};
|
hosts = previousValue.hosts != null ? previousValue.hosts : {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user