@lvce-editor/update-worker 1.4.0 → 1.5.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.
@@ -910,19 +910,11 @@ 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) => {
913
+ const downloadToDisk = async (diskPath, response) => {
918
914
  // @ts-ignore
919
- const cacheDir = await invoke('PlatformPaths.getCacheDir');
920
- const baseName = getBaseName(downloadUrl);
921
- const diskPath = `${cacheDir}/${baseName}`;
922
915
  const blob = await response.blob();
923
916
  // @ts-ignore
924
917
  await invoke('FileSystem.writeBlob', diskPath, blob);
925
- return diskPath;
926
918
  };
927
919
 
928
920
  const downloadUpdate = async updateUrl => {
@@ -945,6 +937,11 @@ const downloadUpdateToCache = async (downloadUrl, cache) => {
945
937
  await putInCache(downloadUrl, response, cache);
946
938
  };
947
939
 
940
+ const existsFile = uri => {
941
+ // @ts-ignore
942
+ return invoke('FileSystem.exists', uri);
943
+ };
944
+
948
945
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
949
946
 
950
947
  const cachedCaches = Object.create(null);
@@ -979,6 +976,18 @@ const getCache = (bucketName, cacheName) => {
979
976
  return cachedCaches[cacheName];
980
977
  };
981
978
 
979
+ const getBaseName = downloadUrl => {
980
+ const lastSlashIndex = downloadUrl.lastIndexOf('/');
981
+ return downloadUrl.slice(lastSlashIndex + 1);
982
+ };
983
+ const getDiskPath = async downloadUrl => {
984
+ // @ts-ignore
985
+ const cacheDir = await invoke('PlatformPaths.getCachePath');
986
+ const baseName = getBaseName(downloadUrl);
987
+ const diskPath = `${cacheDir}/${baseName}`;
988
+ return diskPath;
989
+ };
990
+
982
991
  const parseVersionFromUrl = (url, repository) => {
983
992
  if (!url.includes('releases/tag')) {
984
993
  if (url.endsWith('/releases')) {
@@ -1108,7 +1117,10 @@ const checkForUpdates = async (updateSetting, repository) => {
1108
1117
  error: undefined
1109
1118
  };
1110
1119
  }
1111
- const diskPath = await downloadToDisk(downloadUrl, response);
1120
+ const diskPath = await getDiskPath(downloadUrl);
1121
+ if (!(await existsFile(diskPath))) {
1122
+ await downloadToDisk(downloadUrl, response);
1123
+ }
1112
1124
  await installAndRestart(diskPath);
1113
1125
  return {
1114
1126
  updated: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/update-worker",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Update Worker",
5
5
  "repository": {
6
6
  "type": "git",