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

Improve latest download (2.0) #323

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

config/local.js
database.json

releases



Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ If you host your project on your Github **and** do not need a UI for your app, t
- :sparkles: Simple but powerful download urls (**NOTE:** when no assets are uploaded, server returns `404` by default):
- `/download/latest`
- `/download/latest/:platform`
- `/download/latest/:platform/:filename`
- `/download/:version`
- `/download/:version/:platform`
- `/download/:version/:platform/:filename`
- `/download/channel/:channel`
- `/download/channel/:channel/:platform`
- `/download/channel/:channel/:platform/:filename`
- `/download/flavor/:flavor/latest`
- `/download/flavor/:flavor/latest/:platform`
- `/download/flavor/:flavor/latest/:platform/:filename`
- `/download/flavor/:flavor/latest/channel/:channel/`
- `/download/flavor/:flavor/latest/channel/:channel/:platform`
- `/download/flavor/:flavor/latest/channel/:channel/:platform/:filename`
- `/download/flavor/:flavor/:version`
- `/download/flavor/:flavor/:version/:platform`
- `/download/flavor/:flavor/:version/:platform/:filename`
Expand Down
11 changes: 6 additions & 5 deletions api/controllers/AssetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var _ = require('lodash');
var path = require('path');
var actionUtil = require('sails/lib/hooks/blueprints/actionUtil');
var Promise = require('bluebird');
const PlatformService = require('../services/PlatformService');

module.exports = {

Expand All @@ -19,12 +20,12 @@ module.exports = {
* This is because Squirrel.Windows does a poor job of parsing the filename,
* and so we must fake the filenames of x32 and x64 versions to be the same.
*
* (GET /download/latest/:platform?': 'AssetController.download')
* (GET /download/latest/:platform?/:filename?': 'AssetController.download')
* (GET /download/:version/:platform?/:filename?': 'AssetController.download')
* (GET /download/channel/:channel/:platform?': 'AssetController.download')
* (GET /download/flavor/:flavor/latest/:platform?': 'AssetController.download')
* (GET /download/channel/:channel/:platform?/:filename?': 'AssetController.download')
* (GET /download/flavor/:flavor/latest/:platform?/:filename?': 'AssetController.download')
* (GET /download/flavor/:flavor/:version/:platform?/:filename?': 'AssetController.download')
* (GET /download/flavor/:flavor/channel/:channel/:platform?': 'AssetController.download')
* (GET /download/flavor/:flavor/channel/:channel/:platform?/:filename?': 'AssetController.download')
*/
download: function(req, res) {
var channel = req.params.channel;
Expand All @@ -37,7 +38,7 @@ module.exports = {
var platforms;
var platform = req.param('platform');
if (platform) {
platforms = [platform];
platforms = PlatformService.detect(platform, true);
}

// Normalize filetype by prepending with period
Expand Down
36 changes: 30 additions & 6 deletions config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,48 @@ module.exports.routes = {
'/auth/logout': { view: 'homepage' },

'PUT /version/availability/:version/:timestamp': 'VersionController.availability',

'GET /download/latest/:platform?': 'AssetController.download',
'GET /download/channel/:channel/:platform?': 'AssetController.download',
'GET /download/latest/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/channel/:channel/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/:version/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/flavor/:flavor/latest/:platform?': 'AssetController.download',
'GET /download/flavor/:flavor/channel/:channel/:platform?': 'AssetController.download',
'GET /download/flavor/:flavor/latest/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/flavor/:flavor/channel/:channel/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/flavor/:flavor/latest/channel/:channel/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},
'GET /download/flavor/:flavor/:version/:platform?/:filename?': {
controller: 'AssetController',
action: 'download',
// This is important since it allows matching with filenames.
skipAssets: false
},

'GET /update': 'VersionController.redirect',
'GET /update/:platform/latest-mac.yml': 'VersionController.electronUpdaterMac',
'GET /update/:platform/:channel-mac.yml': 'VersionController.electronUpdaterMac',
Expand Down
4 changes: 4 additions & 0 deletions docs/urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Electron Release Server provides a variety of urls to access release assets.
#### Latest version for specific platform:
- `http://download.myapp.com/download/latest/osx`
- `http://download.myapp.com/download/flavor/default/latest/osx`
#### Latest version for specific platform and file extension
- `http://download.myapp.com/download/latest/osx/update.zip`
- `http://download.myapp.com/download/flavor/default/latest/osx/update.dmg`
- `http://download.myapp.com/download/flavor/default/latest/channel/stable/osx/update.dmg`
#### Specific version for detected platform:
- `http://download.myapp.com/download/1.1.0`
- `http://download.myapp.com/download/flavor/default/1.1.0`
Expand Down