@lvce-editor/update-worker 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/updateWorkerMain.js +25 -3
- package/package.json +1 -1
package/dist/updateWorkerMain.js
CHANGED
|
@@ -1083,7 +1083,7 @@ const shouldUpdate = async (updateSetting, version) => {
|
|
|
1083
1083
|
return shouldUpdate;
|
|
1084
1084
|
};
|
|
1085
1085
|
|
|
1086
|
-
const
|
|
1086
|
+
const doCheckForUpdates = async (updateSetting, repository, bucketName, cacheName) => {
|
|
1087
1087
|
try {
|
|
1088
1088
|
if (!isOnline()) {
|
|
1089
1089
|
return {
|
|
@@ -1091,8 +1091,6 @@ const checkForUpdates = async (updateSetting, repository) => {
|
|
|
1091
1091
|
error: undefined
|
|
1092
1092
|
};
|
|
1093
1093
|
}
|
|
1094
|
-
const bucketName = 'electron-updates';
|
|
1095
|
-
const cacheName = 'electron-updates';
|
|
1096
1094
|
const info = await getLatestReleaseVersion(repository);
|
|
1097
1095
|
if (!info || !info.version) {
|
|
1098
1096
|
return {
|
|
@@ -1150,6 +1148,30 @@ const checkForUpdates = async (updateSetting, repository) => {
|
|
|
1150
1148
|
}
|
|
1151
1149
|
};
|
|
1152
1150
|
|
|
1151
|
+
const requestLock = async (lockName, callback) => {
|
|
1152
|
+
const result = await navigator.locks.request(lockName, {
|
|
1153
|
+
ifAvailable: true
|
|
1154
|
+
}, callback);
|
|
1155
|
+
return result;
|
|
1156
|
+
};
|
|
1157
|
+
|
|
1158
|
+
const checkForUpdates = async (updateSetting, repository) => {
|
|
1159
|
+
const lockName = 'electron-updates';
|
|
1160
|
+
const bucketName = 'electron-updates';
|
|
1161
|
+
const cacheName = 'electron-updates';
|
|
1162
|
+
const result = await requestLock(lockName, async lock => {
|
|
1163
|
+
if (!lock) {
|
|
1164
|
+
return {
|
|
1165
|
+
updated: false,
|
|
1166
|
+
error: undefined
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
const result = await doCheckForUpdates(updateSetting, repository, bucketName, cacheName);
|
|
1170
|
+
return result;
|
|
1171
|
+
});
|
|
1172
|
+
return result;
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1153
1175
|
const commandMap = {
|
|
1154
1176
|
'Update.downloadToCache': downloadUpdateToCache,
|
|
1155
1177
|
'Update.checkForUpdates': checkForUpdates
|