Windows Portable App (#417)
* packager: call callbacks consistently Before this, the callbacks would not being called, which would lead to an incomplete build on non-OS X platforms when trying to build all for all platforms. * packager: Always produce OS X update file regardless of --package option This makes it consistent with how the windows build always produces the .nupkg autoupdate files * packager: fix duplicate npm install Move "npm prune && npm dedupe" into the release script. Remove an extra "npm install" * Make Windows portable app When a folder named "Portable Settings" exists in same folder as WebTorrent.exe, then use it instead of the default application config path. Closes #358 * packager: remove redundant signing warning * cross platform zip function * Set config file path to match config.CONFIG_PATH * portable app: make electron settings portable * portable: fix poster/torrent paths * use cross-zip * portable app: default download folder inside 'Portable Settings'
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
console.time('init')
|
||||
|
||||
var cfg = require('application-config')('WebTorrent')
|
||||
var appConfig = require('application-config')('WebTorrent')
|
||||
var concat = require('concat-stream')
|
||||
var dragDrop = require('drag-drop')
|
||||
var electron = require('electron')
|
||||
@@ -26,6 +26,8 @@ var util = require('./util')
|
||||
var {setDispatch} = require('./lib/dispatcher')
|
||||
setDispatch(dispatch)
|
||||
|
||||
appConfig.filePath = config.CONFIG_PATH + path.sep + 'config.json'
|
||||
|
||||
// Electron apps have two processes: a main process (node) runs first and starts
|
||||
// a renderer process (essentially a Chrome window). We're in the renderer process,
|
||||
// and this IPC channel receives from and sends messages to the main process
|
||||
@@ -425,9 +427,9 @@ function setupIpc () {
|
||||
|
||||
// Load state.saved from the JSON state file
|
||||
function loadState (cb) {
|
||||
cfg.read(function (err, data) {
|
||||
appConfig.read(function (err, data) {
|
||||
if (err) console.error(err)
|
||||
console.log('loaded state from ' + cfg.filePath)
|
||||
console.log('loaded state from ' + appConfig.filePath)
|
||||
|
||||
// populate defaults if they're not there
|
||||
state.saved = Object.assign({}, State.getDefaultSavedState(), data)
|
||||
@@ -457,7 +459,7 @@ function saveStateThrottled () {
|
||||
|
||||
// Write state.saved to the JSON state file
|
||||
function saveState () {
|
||||
console.log('saving state to ' + cfg.filePath)
|
||||
console.log('saving state to ' + appConfig.filePath)
|
||||
|
||||
// Clean up, so that we're not saving any pending state
|
||||
var copy = Object.assign({}, state.saved)
|
||||
@@ -479,7 +481,7 @@ function saveState () {
|
||||
return torrent
|
||||
})
|
||||
|
||||
cfg.write(copy, function (err) {
|
||||
appConfig.write(copy, function (err) {
|
||||
if (err) console.error(err)
|
||||
ipcRenderer.send('savedState')
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var electron = require('electron')
|
||||
var path = require('path')
|
||||
|
||||
var remote = electron.remote
|
||||
|
||||
@@ -255,6 +256,8 @@ function getDefaultSavedState () {
|
||||
]
|
||||
}
|
||||
],
|
||||
downloadPath: remote.app.getPath('downloads')
|
||||
downloadPath: config.IS_PORTABLE
|
||||
? path.join(config.CONFIG_PATH, 'Downloads')
|
||||
: remote.app.getPath('downloads')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user