@lvce-editor/update-worker 1.9.0 → 2.0.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.
@@ -909,8 +909,16 @@ const confirmPrompt = async message => {
909
909
  return result;
910
910
  };
911
911
 
912
+ const getParentPath = path => {
913
+ const slashIndex = path.lastIndexOf('/');
914
+ if (slashIndex === -1) {
915
+ return '';
916
+ }
917
+ return path.slice(0, slashIndex);
918
+ };
912
919
  const downloadToDisk = async (diskPath, response) => {
913
- // @ts-ignore
920
+ const parentPath = getParentPath(diskPath);
921
+ await invoke('FileSystem.mkdir', parentPath);
914
922
  const blob = await response.blob();
915
923
  // @ts-ignore
916
924
  await invoke('FileSystem.writeBlob', diskPath, blob);
@@ -979,9 +987,10 @@ const getBaseName = downloadUrl => {
979
987
  const lastSlashIndex = downloadUrl.lastIndexOf('/');
980
988
  return downloadUrl.slice(lastSlashIndex + 1);
981
989
  };
990
+
982
991
  const getDiskPath = async downloadUrl => {
983
992
  // @ts-ignore
984
- const cacheDir = await invoke('PlatformPaths.getCachePath');
993
+ const cacheDir = await invoke('PlatformPaths.getCacheUri');
985
994
  const baseName = getBaseName(downloadUrl);
986
995
  const diskPath = `${cacheDir}/auto-updater/${baseName}`;
987
996
  return diskPath;
@@ -1128,7 +1137,7 @@ const doCheckForUpdates = async (updateSetting, repository, fileNameTemplate, bu
1128
1137
  }
1129
1138
  const diskPath = await getDiskPath(downloadUrl);
1130
1139
  if (!(await existsFile(diskPath))) {
1131
- await downloadToDisk(downloadUrl, response);
1140
+ await downloadToDisk(diskPath, response);
1132
1141
  }
1133
1142
  await installAndRestart(diskPath);
1134
1143
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/update-worker",
3
- "version": "1.9.0",
3
+ "version": "2.0.0",
4
4
  "description": "Update Worker",
5
5
  "repository": {
6
6
  "type": "git",