Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Delta versions #111

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions api/controllers/VersionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,16 @@ module.exports = {
_.remove(newVersion.assets, function(o) {
return o.filetype !== '.nupkg' || !o.hash;
});
return newVersion.assets.length && semver.lte(

// Make sure the last version is a version with full asset
// so RELEASES contains at least one full asset (which is mandatory for Squirrel.Windows)
let v = _.filter(
newVersion.assets,
function(o) {
return _.includes(o.name.toLowerCase(), '-full');
}
);
return v.length && semver.lte(
version, newVersion.name
);
});
Expand All @@ -231,13 +240,34 @@ module.exports = {
return res.status(500).send('Version not found');
}

// Add Delta assets from other versions
var deltaAssets = _.reduce(
newerVersions,
function(assets, newVersion) {
return assets.concat(
_.filter(
newVersion.assets,
function(asset) {
return asset.filetype === '.nupkg'
&& _.includes(asset.name.toLowerCase(), '-delta')
&& semver.lte(version, asset.version)
&& semver.gt(latestVersion.name, asset.version);
}));
}, []);

Array.prototype.unshift.apply(latestVersion.assets, deltaAssets);

latestVersion.assets.sort(function(a1, a2) {
return semver.compare(a1.version, a2.version);
});

sails.log.debug('Latest Windows Version', latestVersion);

// Change asset name to use full download link
assets = _.map(latestVersion.assets, function(asset) {
asset.name = url.resolve(
sails.config.appUrl,
'/download/' + latestVersion.name + '/' + asset.platform + '/' +
'/download/' + asset.version + '/' + asset.platform + '/' +
asset.name
);

Expand Down