-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
P2P updater #473
P2P updater #473
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,5 @@ var | |
|
||
// Torrent engines | ||
peerflix = require('peerflix'), | ||
|
||
// NodeJS | ||
child = require('child_process'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,7 @@ Settings.tmpLocation = path.join(os.tmpDir(), Settings.projectName); | |
Settings.databaseLocation = path.join(data_path, 'data'); | ||
Settings.deleteTmpOnClose = true; | ||
Settings.automaticUpdating = true; | ||
Settings.UpdateSeed = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Settings.seedUpdate is a parameter on setting container , There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's just a name nitpick 'seedUpdate' isn't really clear to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how windowsy of you There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. naming convention is bad, you should use seedUpdate or redistributeUpdater, but don't start with an uppercase :) |
||
Settings.events = true; | ||
Settings.minimizeToTray = false; | ||
Settings.bigPicture = false; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,8 +556,12 @@ | |
<label class="settings-label" for="cb5"><%= i18n.__("Activate automatic updating") %></label> | ||
</span> | ||
<span> | ||
<input class="settings-checkbox" name="events" id="cb6" type="checkbox" <%=(Settings.events? "checked='checked'":"")%>> | ||
<label class="settings-label" for="cb6"><%= i18n.__("Celebrate various events") %></label> | ||
<input class="settings-checkbox" name="UpdateSeed" id="cb6" type="checkbox" <%=(Settings.UpdateSeed? "checked='checked'":"")%>> | ||
<label class="settings-label" for="cb6"><%= i18n.__("Activate Update Seeding") %></label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's personnal and doesn't really impair the merge of this, but I don't like the string. For starter, you don't need the word "activate" in it, the checkbox says that already.
|
||
</span> | ||
<span> | ||
<input class="settings-checkbox" name="events" id="cb7" type="checkbox" <%=(Settings.events? "checked='checked'":"")%>> | ||
<label class="settings-label" for="cb7"><%= i18n.__("Celebrate various events") %></label> | ||
</span> | ||
<span> | ||
<input class="settings-checkbox" name="minimizeToTray" id="minimizeToTray" type="checkbox" <%=(Settings.minimizeToTray? "checked='checked'":"")%>> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
|
||
var CHANNELS = ['stable', 'beta', 'nightly'], | ||
FILENAME = 'package.nw.new', | ||
WebTorrent = require('webtorrent'), | ||
client = new WebTorrent({dht: true,maxConns: '5'}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the maxConns needed? It fallsback to 55, why forcing a lower number? |
||
VERIFY_PUBKEY = Settings.updateKey; | ||
|
||
function forcedBind(func, thisVar) { | ||
|
@@ -19,7 +21,7 @@ | |
var self = this; | ||
|
||
this.options = _.defaults(options || {}, { | ||
endpoint: AdvSettings.get('updateEndpoint').url + 'update3.json' + '?version=' + App.settings.version + '&nwversion=' + process.versions['node-webkit'], | ||
endpoint: AdvSettings.get('updateEndpoint').url + 'p2pudpate.json' + '?version=' + App.settings.version + '&nwversion=' + process.versions['node-webkit'], | ||
channel: 'beta' | ||
}); | ||
|
||
|
@@ -77,21 +79,44 @@ | |
self.updateData = updateData; | ||
return true; | ||
} | ||
if (App.settings.UpdateSeed) { | ||
client.add(updateData.UpdateUrl, { path: os.tmpdir() }, function (torrent) { | ||
torrent.on('error', function (err) { | ||
win.debug('ERROR' + err.message); | ||
}); | ||
torrent.on('done', function () { | ||
win.debug('Seeding the Current Update!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once 'done', it doesn't seed, according to my tests. You need to explicitly set it with the .seed() api call (I think?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it looks like seed() is to create a new torrent, i'm not sure how seed control works... |
||
}); | ||
}); | ||
} | ||
|
||
win.debug('Not updating because we are running the latest version'); | ||
return false; | ||
}); | ||
}; | ||
|
||
Updater.prototype.download = function (source, output) { | ||
|
||
|
||
Updater.prototype.download = function (source, outputDir) { | ||
var defer = Q.defer(); | ||
var downloadStream = request(source); | ||
win.debug('Downloading update... Please allow a few minutes'); | ||
downloadStream.pipe(fs.createWriteStream(output)); | ||
downloadStream.on('complete', function () { | ||
win.debug('Update downloaded!'); | ||
defer.resolve(output); | ||
client.on('error', function (err) { | ||
win.debug('ERROR: ' + err.message); | ||
defer.reject(err); | ||
}); | ||
|
||
client.add(source, { | ||
path: outputDir | ||
}, function (torrent) { | ||
win.debug('Downloading update... Please allow a few minutes'); | ||
torrent.on('error', function (err) { | ||
win.debug('ERROR' + err.message); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be |
||
defer.reject(err); | ||
}); | ||
torrent.on('done', function () { | ||
win.debug('Update downloaded!'); | ||
defer.resolve(path.join(outputDir, torrent.name)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. torrent.name contains the extension of the file in this case? Because there's a risk it's a directory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we create the update torrent. |
||
}); | ||
}); | ||
|
||
return defer.promise; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use 0.x.x or ^0.97.2