@lvce-editor/update-worker 1.3.0 → 1.4.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 +24 -2
- package/package.json +1 -1
package/dist/updateWorkerMain.js
CHANGED
|
@@ -910,6 +910,21 @@ const confirmPrompt = async message => {
|
|
|
910
910
|
return true;
|
|
911
911
|
};
|
|
912
912
|
|
|
913
|
+
const getBaseName = downloadUrl => {
|
|
914
|
+
const lastSlashIndex = downloadUrl.lastIndexOf('/');
|
|
915
|
+
return downloadUrl.slice(lastSlashIndex + 1);
|
|
916
|
+
};
|
|
917
|
+
const downloadToDisk = async (downloadUrl, response) => {
|
|
918
|
+
// @ts-ignore
|
|
919
|
+
const cacheDir = await invoke('PlatformPaths.getCacheDir');
|
|
920
|
+
const baseName = getBaseName(downloadUrl);
|
|
921
|
+
const diskPath = `${cacheDir}/${baseName}`;
|
|
922
|
+
const blob = await response.blob();
|
|
923
|
+
// @ts-ignore
|
|
924
|
+
await invoke('FileSystem.writeBlob', diskPath, blob);
|
|
925
|
+
return diskPath;
|
|
926
|
+
};
|
|
927
|
+
|
|
913
928
|
const downloadUpdate = async updateUrl => {
|
|
914
929
|
const response = await fetch(updateUrl, {
|
|
915
930
|
priority: 'low',
|
|
@@ -1086,8 +1101,15 @@ const checkForUpdates = async (updateSetting, repository) => {
|
|
|
1086
1101
|
error: undefined
|
|
1087
1102
|
};
|
|
1088
1103
|
}
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1104
|
+
const response = await cache.match(downloadUrl);
|
|
1105
|
+
if (!response) {
|
|
1106
|
+
return {
|
|
1107
|
+
updated: false,
|
|
1108
|
+
error: undefined
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
const diskPath = await downloadToDisk(downloadUrl, response);
|
|
1112
|
+
await installAndRestart(diskPath);
|
|
1091
1113
|
return {
|
|
1092
1114
|
updated: true,
|
|
1093
1115
|
error: undefined
|