Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
load https-e listeners even if db hasn't finished loading
Browse files Browse the repository at this point in the history
It seems that usually the rulesets have loaded by the time the first network request
happens. So instead of aborting if the rulesets haven't loaded, load the listeners anyway.
  • Loading branch information
diracdeltas committed Jan 13, 2016
1 parent 405c6e4 commit df71e4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions app/dataFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ function downloadSingleFile (resourceName, url, version, force, resolve, reject)
AppActions.setResourceETag(resourceName, etag)

req.pipe(fs.createWriteStream(downloadPath(url)).on('close', function () {
console.log('wrote', storagePath(url))
fs.rename(downloadPath(url), storagePath(url), function (err) {
if (err) {
reject('could not rename downloaded file')
} else {
console.log('renamed', storagePath(url))
resolve()
}
})
Expand Down
12 changes: 7 additions & 5 deletions app/httpsEverywhere.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function getHostnamePatterns (url) {
// copy the original array
var tmp = segmented.slice()
if (label.length === 0) {
console.log('got host with 0-length label', host)
console.log('got host with 0-length label', url)
} else {
tmp[index] = '*'
hostPatterns.push(tmp.join('*'))
Expand All @@ -106,6 +106,12 @@ function getHostnamePatterns (url) {
function loadRulesetsById (rulesetIds, cb, errback) {
var ids = JSON.stringify(rulesetIds).replace('[', '(').replace(']', ')')
var queryForRuleset = 'select contents from rulesets where id in ' + ids
if (!dbLoaded || db === null) {
// This request occurred before the db finished loading
console.log('got request that occurred before HTTPS Everywhere loaded')
errback()
return
}
db.all(queryForRuleset, function (err, rows) {
var applicableRules
try {
Expand Down Expand Up @@ -210,10 +216,6 @@ module.exports.init = (win) => {
}

function startHttpsEverywhere (win) {
if (!dbLoaded) {
console.log('httpse db not loaded yet; aborting')
return null
}
var session = win.webContents ? win.webContents.session : null
if (!session) {
console.log('could not get window session')
Expand Down

0 comments on commit df71e4e

Please sign in to comment.