diff options
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/api/server/ServerApi.js | 56 | ||||
-rw-r--r-- | src/stores/AppStore.js | 2 | ||||
-rw-r--r-- | src/stores/RecipesStore.js | 4 | ||||
-rw-r--r-- | yarn.lock | 64 |
5 files changed, 81 insertions, 47 deletions
diff --git a/package.json b/package.json index ab93f455b..2457c05a9 100644 --- a/package.json +++ b/package.json | |||
@@ -64,7 +64,7 @@ | |||
64 | "react-tooltip": "^3.2.7", | 64 | "react-tooltip": "^3.2.7", |
65 | "route-parser": "^0.0.5", | 65 | "route-parser": "^0.0.5", |
66 | "smoothscroll-polyfill": "^0.3.4", | 66 | "smoothscroll-polyfill": "^0.3.4", |
67 | "tar.gz": "^1.0.5", | 67 | "tar": "^4.0.2", |
68 | "uuid": "^3.0.1" | 68 | "uuid": "^3.0.1" |
69 | }, | 69 | }, |
70 | "devDependencies": { | 70 | "devDependencies": { |
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js index 86f4c99e7..8b0b7563c 100644 --- a/src/api/server/ServerApi.js +++ b/src/api/server/ServerApi.js | |||
@@ -1,6 +1,6 @@ | |||
1 | import os from 'os'; | 1 | import os from 'os'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import targz from 'tar.gz'; | 3 | import tar from 'tar'; |
4 | import fs from 'fs-extra'; | 4 | import fs from 'fs-extra'; |
5 | import { remote } from 'electron'; | 5 | import { remote } from 'electron'; |
6 | 6 | ||
@@ -293,7 +293,11 @@ export default class ServerApi { | |||
293 | const buffer = await res.buffer(); | 293 | const buffer = await res.buffer(); |
294 | fs.writeFileSync(archivePath, buffer); | 294 | fs.writeFileSync(archivePath, buffer); |
295 | 295 | ||
296 | await targz().extract(archivePath, recipeTempDirectory); | 296 | tar.x({ |
297 | file: archivePath, | ||
298 | cwd: recipeTempDirectory, | ||
299 | sync: true, | ||
300 | }); | ||
297 | 301 | ||
298 | const { id } = fs.readJsonSync(path.join(recipeTempDirectory, 'package.json')); | 302 | const { id } = fs.readJsonSync(path.join(recipeTempDirectory, 'package.json')); |
299 | const recipeDirectory = path.join(recipesDirectory, id); | 303 | const recipeDirectory = path.join(recipesDirectory, id); |
@@ -443,6 +447,10 @@ export default class ServerApi { | |||
443 | 447 | ||
444 | // Helper | 448 | // Helper |
445 | async _mapServiceModels(services) { | 449 | async _mapServiceModels(services) { |
450 | const recipes = services.map(s => s.recipeId); | ||
451 | |||
452 | await this._bulkRecipeCheck(recipes); | ||
453 | |||
446 | return Promise.all(services | 454 | return Promise.all(services |
447 | .map(async service => await this._prepareServiceModel(service)) // eslint-disable-line | 455 | .map(async service => await this._prepareServiceModel(service)) // eslint-disable-line |
448 | ); | 456 | ); |
@@ -454,19 +462,8 @@ export default class ServerApi { | |||
454 | recipe = this.recipes.find(r => r.id === service.recipeId); | 462 | recipe = this.recipes.find(r => r.id === service.recipeId); |
455 | 463 | ||
456 | if (!recipe) { | 464 | if (!recipe) { |
457 | console.warn(`Recipe '${service.recipeId}' not installed, trying to fetch from server`); | 465 | console.warn(`Recipe ${service.recipeId} not loaded`); |
458 | 466 | return null; | |
459 | await this.getRecipePackage(service.recipeId); | ||
460 | |||
461 | console.debug('Rerun ServerAPI::getInstalledRecipes'); | ||
462 | await this.getInstalledRecipes(); | ||
463 | |||
464 | recipe = this.recipes.find(r => r.id === service.recipeId); | ||
465 | |||
466 | if (!recipe) { | ||
467 | console.warn(`Could not load recipe ${service.recipeId}`); | ||
468 | return null; | ||
469 | } | ||
470 | } | 467 | } |
471 | 468 | ||
472 | return new ServiceModel(service, recipe); | 469 | return new ServiceModel(service, recipe); |
@@ -476,6 +473,35 @@ export default class ServerApi { | |||
476 | } | 473 | } |
477 | } | 474 | } |
478 | 475 | ||
476 | async _bulkRecipeCheck(unfilteredRecipes) { | ||
477 | // Filter recipe duplicates as we don't need to download 3 Slack recipes | ||
478 | const recipes = unfilteredRecipes.filter((elem, pos, arr) => arr.indexOf(elem) === pos); | ||
479 | |||
480 | return Promise.all(recipes | ||
481 | .map(async (recipeId) => { | ||
482 | let recipe = this.recipes.find(r => r.id === recipeId); | ||
483 | |||
484 | if (!recipe) { | ||
485 | console.warn(`Recipe '${recipeId}' not installed, trying to fetch from server`); | ||
486 | |||
487 | await this.getRecipePackage(recipeId); | ||
488 | |||
489 | console.debug('Rerun ServerAPI::getInstalledRecipes'); | ||
490 | await this.getInstalledRecipes(); | ||
491 | |||
492 | recipe = this.recipes.find(r => r.id === recipeId); | ||
493 | |||
494 | if (!recipe) { | ||
495 | console.warn(`Could not load recipe ${recipeId}`); | ||
496 | return null; | ||
497 | } | ||
498 | } | ||
499 | |||
500 | return recipe; | ||
501 | }), | ||
502 | ).catch(err => console.error(err)); | ||
503 | } | ||
504 | |||
479 | _mapRecipePreviewModel(recipes) { | 505 | _mapRecipePreviewModel(recipes) { |
480 | return recipes.map((recipe) => { | 506 | return recipes.map((recipe) => { |
481 | try { | 507 | try { |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 8435c9ab8..7dbef985d 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -80,7 +80,7 @@ export default class AppStore extends Store { | |||
80 | // Check for updates once every 4 hours | 80 | // Check for updates once every 4 hours |
81 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); | 81 | setInterval(() => this._checkForUpdates(), CHECK_INTERVAL); |
82 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) | 82 | // Check for an update in 30s (need a delay to prevent Squirrel Installer lock file issues) |
83 | setTimeout(() => this._checkForUpdates(), 3000); | 83 | setTimeout(() => this._checkForUpdates(), 30000); |
84 | ipcRenderer.on('autoUpdate', (event, data) => { | 84 | ipcRenderer.on('autoUpdate', (event, data) => { |
85 | if (data.available) { | 85 | if (data.available) { |
86 | this.updateStatus = this.updateStatusTypes.AVAILABLE; | 86 | this.updateStatus = this.updateStatusTypes.AVAILABLE; |
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index cdc274685..67fee1d50 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js | |||
@@ -65,6 +65,10 @@ export default class RecipesStore extends Store { | |||
65 | @action async _update() { | 65 | @action async _update() { |
66 | const recipeIds = this.recipeIdForServices; | 66 | const recipeIds = this.recipeIdForServices; |
67 | const recipes = {}; | 67 | const recipes = {}; |
68 | |||
69 | // Hackfix, reference this.all to fetch services | ||
70 | console.debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); | ||
71 | |||
68 | recipeIds.forEach((r) => { | 72 | recipeIds.forEach((r) => { |
69 | const recipe = this.one(r); | 73 | const recipe = this.one(r); |
70 | recipes[r] = recipe.version; | 74 | recipes[r] = recipe.version; |
@@ -1174,10 +1174,6 @@ bluebird-lst@^1.0.2, bluebird-lst@^1.0.3: | |||
1174 | dependencies: | 1174 | dependencies: |
1175 | bluebird "^3.5.0" | 1175 | bluebird "^3.5.0" |
1176 | 1176 | ||
1177 | bluebird@^2.9.34: | ||
1178 | version "2.11.0" | ||
1179 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" | ||
1180 | |||
1181 | bluebird@^3.1.1, bluebird@^3.4.7, bluebird@^3.5.0: | 1177 | bluebird@^3.1.1, bluebird@^3.4.7, bluebird@^3.5.0: |
1182 | version "3.5.0" | 1178 | version "3.5.0" |
1183 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" | 1179 | resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" |
@@ -1322,6 +1318,10 @@ chokidar@^1.4.3: | |||
1322 | optionalDependencies: | 1318 | optionalDependencies: |
1323 | fsevents "^1.0.0" | 1319 | fsevents "^1.0.0" |
1324 | 1320 | ||
1321 | chownr@^1.0.1: | ||
1322 | version "1.0.1" | ||
1323 | resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" | ||
1324 | |||
1325 | chromium-pickle-js@^0.2.0: | 1325 | chromium-pickle-js@^0.2.0: |
1326 | version "0.2.0" | 1326 | version "0.2.0" |
1327 | resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205" | 1327 | resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205" |
@@ -2652,7 +2652,7 @@ fstream-ignore@^1.0.5: | |||
2652 | inherits "2" | 2652 | inherits "2" |
2653 | minimatch "^3.0.0" | 2653 | minimatch "^3.0.0" |
2654 | 2654 | ||
2655 | fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2, fstream@^1.0.8: | 2655 | fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: |
2656 | version "1.0.11" | 2656 | version "1.0.11" |
2657 | resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" | 2657 | resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" |
2658 | dependencies: | 2658 | dependencies: |
@@ -3174,11 +3174,7 @@ hyperquest@~1.2.0: | |||
3174 | duplexer2 "~0.0.2" | 3174 | duplexer2 "~0.0.2" |
3175 | through2 "~0.6.3" | 3175 | through2 "~0.6.3" |
3176 | 3176 | ||
3177 | iconv-lite@^0.4.17: | 3177 | iconv-lite@^0.4.17, iconv-lite@~0.4.13: |
3178 | version "0.4.19" | ||
3179 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" | ||
3180 | |||
3181 | iconv-lite@~0.4.13: | ||
3182 | version "0.4.18" | 3178 | version "0.4.18" |
3183 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" | 3179 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" |
3184 | 3180 | ||
@@ -4135,6 +4131,18 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: | |||
4135 | version "1.2.0" | 4131 | version "1.2.0" |
4136 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" | 4132 | resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" |
4137 | 4133 | ||
4134 | minipass@^2.2.1: | ||
4135 | version "2.2.1" | ||
4136 | resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.1.tgz#5ada97538b1027b4cf7213432428578cb564011f" | ||
4137 | dependencies: | ||
4138 | yallist "^3.0.0" | ||
4139 | |||
4140 | minizlib@^1.0.4: | ||
4141 | version "1.0.4" | ||
4142 | resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.0.4.tgz#8ebb51dd8bbe40b0126b5633dbb36b284a2f523c" | ||
4143 | dependencies: | ||
4144 | minipass "^2.2.1" | ||
4145 | |||
4138 | mkdirp@0.5.0: | 4146 | mkdirp@0.5.0: |
4139 | version "0.5.0" | 4147 | version "0.5.0" |
4140 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" | 4148 | resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" |
@@ -4183,10 +4191,6 @@ moment@2.x.x, moment@^2.17.1: | |||
4183 | version "2.18.1" | 4191 | version "2.18.1" |
4184 | resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" | 4192 | resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" |
4185 | 4193 | ||
4186 | mout@^0.11.0: | ||
4187 | version "0.11.1" | ||
4188 | resolved "https://registry.yarnpkg.com/mout/-/mout-0.11.1.tgz#ba3611df5f0e5b1ffbfd01166b8f02d1f5fa2b99" | ||
4189 | |||
4190 | ms@0.6.2: | 4194 | ms@0.6.2: |
4191 | version "0.6.2" | 4195 | version "0.6.2" |
4192 | resolved "https://registry.yarnpkg.com/ms/-/ms-0.6.2.tgz#d89c2124c6fdc1353d65a8b77bf1aac4b193708c" | 4196 | resolved "https://registry.yarnpkg.com/ms/-/ms-0.6.2.tgz#d89c2124c6fdc1353d65a8b77bf1aac4b193708c" |
@@ -4217,14 +4221,10 @@ mute-stream@0.0.4: | |||
4217 | version "0.0.4" | 4221 | version "0.0.4" |
4218 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" | 4222 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.4.tgz#a9219960a6d5d5d046597aee51252c6655f7177e" |
4219 | 4223 | ||
4220 | mute-stream@0.0.7: | 4224 | mute-stream@0.0.7, mute-stream@~0.0.4: |
4221 | version "0.0.7" | 4225 | version "0.0.7" |
4222 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" | 4226 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" |
4223 | 4227 | ||
4224 | mute-stream@~0.0.4: | ||
4225 | version "0.0.5" | ||
4226 | resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" | ||
4227 | |||
4228 | nan@^2.0.0, nan@^2.0.5, nan@^2.3.0, nan@^2.3.2: | 4228 | nan@^2.0.0, nan@^2.0.5, nan@^2.3.0, nan@^2.3.2: |
4229 | version "2.7.0" | 4229 | version "2.7.0" |
4230 | resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" | 4230 | resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46" |
@@ -5716,17 +5716,7 @@ tar-pack@^3.4.0: | |||
5716 | tar "^2.2.1" | 5716 | tar "^2.2.1" |
5717 | uid-number "^0.0.6" | 5717 | uid-number "^0.0.6" |
5718 | 5718 | ||
5719 | tar.gz@^1.0.5: | 5719 | tar@^2.0.0, tar@^2.2.1: |
5720 | version "1.0.5" | ||
5721 | resolved "https://registry.yarnpkg.com/tar.gz/-/tar.gz-1.0.5.tgz#e1ada7e45ef2241b4b1ee58123c8f40b5d3c1bc4" | ||
5722 | dependencies: | ||
5723 | bluebird "^2.9.34" | ||
5724 | commander "^2.8.1" | ||
5725 | fstream "^1.0.8" | ||
5726 | mout "^0.11.0" | ||
5727 | tar "^2.1.1" | ||
5728 | |||
5729 | tar@^2.0.0, tar@^2.1.1, tar@^2.2.1: | ||
5730 | version "2.2.1" | 5720 | version "2.2.1" |
5731 | resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" | 5721 | resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" |
5732 | dependencies: | 5722 | dependencies: |
@@ -5734,6 +5724,16 @@ tar@^2.0.0, tar@^2.1.1, tar@^2.2.1: | |||
5734 | fstream "^1.0.2" | 5724 | fstream "^1.0.2" |
5735 | inherits "2" | 5725 | inherits "2" |
5736 | 5726 | ||
5727 | tar@^4.0.2: | ||
5728 | version "4.0.2" | ||
5729 | resolved "https://registry.yarnpkg.com/tar/-/tar-4.0.2.tgz#e8e22bf3eec330e5c616d415a698395e294e8fad" | ||
5730 | dependencies: | ||
5731 | chownr "^1.0.1" | ||
5732 | minipass "^2.2.1" | ||
5733 | minizlib "^1.0.4" | ||
5734 | mkdirp "^0.5.0" | ||
5735 | yallist "^3.0.2" | ||
5736 | |||
5737 | tempfile@^1.1.1: | 5737 | tempfile@^1.1.1: |
5738 | version "1.1.1" | 5738 | version "1.1.1" |
5739 | resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2" | 5739 | resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-1.1.1.tgz#5bcc4eaecc4ab2c707d8bc11d99ccc9a2cb287f2" |
@@ -6239,6 +6239,10 @@ yallist@^2.1.2: | |||
6239 | version "2.1.2" | 6239 | version "2.1.2" |
6240 | resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" | 6240 | resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" |
6241 | 6241 | ||
6242 | yallist@^3.0.0, yallist@^3.0.2: | ||
6243 | version "3.0.2" | ||
6244 | resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" | ||
6245 | |||
6242 | yargs-parser@^5.0.0: | 6246 | yargs-parser@^5.0.0: |
6243 | version "5.0.0" | 6247 | version "5.0.0" |
6244 | resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-5.0.0.tgz#275ecf0d7ffe05c77e64e7c86e4cd94bf0e1228a" | 6248 | resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-5.0.0.tgz#275ecf0d7ffe05c77e64e7c86e4cd94bf0e1228a" |