diff --git a/patches/hazel-server+5.1.1.patch b/patches/hazel-server+5.1.1.patch --- a/patches/hazel-server+5.1.1.patch +++ b/patches/hazel-server+5.1.1.patch @@ -1,11 +1,31 @@ diff --git a/node_modules/hazel-server/lib/cache.js b/node_modules/hazel-server/lib/cache.js -index 65e9d30..f95f58d 100644 +index 65e9d30..173ea9c 100644 --- a/node_modules/hazel-server/lib/cache.js +++ b/node_modules/hazel-server/lib/cache.js -@@ -105,16 +105,18 @@ module.exports = class Cache { +@@ -1,6 +1,7 @@ + // Packages + const fetch = require('node-fetch') + const retry = require('async-retry') ++const { compare } = require('semver') + const convertStream = require('stream-to-string') + const ms = require('ms') + +@@ -105,19 +106,33 @@ module.exports = class Cache { return } ++ data.sort((a, b) => { ++ const aDate = new Date(a.created_at); ++ const bDate = new Date(b.created_at); ++ ++ if (aDate < bDate) { ++ return 1; ++ } else if (aDate > bDate) { ++ return -1; ++ } ++ return 0; ++ }); ++ + const desktopTagPrefix = 'desktop-'; + const release = data.find(item => { @@ -21,8 +41,13 @@ - const { tag_name } = release + const tag_name = release.tag_name.slice(desktopTagPrefix.length); - if (this.latest.version === tag_name) { - console.log('Cached version is the same as latest') +- if (this.latest.version === tag_name) { +- console.log('Cached version is the same as latest') ++ if (this.latest.version && compare(this.latest.version, tag_name) !== -1) { ++ console.log('Cached version is the same as latest or newer') + this.lastUpdate = Date.now() + return + } diff --git a/node_modules/hazel-server/lib/routes.js b/node_modules/hazel-server/lib/routes.js index bbd6f14..28b7f72 100644 --- a/node_modules/hazel-server/lib/routes.js