fixes for standard v10

This commit is contained in:
Feross Aboukhadijeh
2017-03-01 23:07:10 -08:00
parent 972203d675
commit c764bf4884
4 changed files with 16 additions and 12 deletions

View File

@@ -17,8 +17,8 @@ let proc = null
function checkInstall (playerPath, cb) { function checkInstall (playerPath, cb) {
// check for VLC if external player has not been specified by the user // check for VLC if external player has not been specified by the user
// otherwise assume the player is installed // otherwise assume the player is installed
if (playerPath == null) return vlcCommand((err) => cb(!err)) if (playerPath == null) return vlcCommand(cb)
process.nextTick(() => cb(true)) process.nextTick(() => cb(null))
} }
function spawn (playerPath, url, title) { function spawn (playerPath, url, title) {

View File

@@ -166,8 +166,8 @@ function init () {
ipc.on('checkForExternalPlayer', function (e, path) { ipc.on('checkForExternalPlayer', function (e, path) {
const externalPlayer = require('./external-player') const externalPlayer = require('./external-player')
externalPlayer.checkInstall(path, function (isInstalled) { externalPlayer.checkInstall(path, function (err) {
windows.main.send('checkForExternalPlayer', isInstalled) windows.main.send('checkForExternalPlayer', !err)
}) })
}) })

View File

@@ -36,8 +36,8 @@ function setWindowFocus (flag) {
} }
function initLinux () { function initLinux () {
checkLinuxTraySupport(function (supportsTray) { checkLinuxTraySupport(function (err) {
if (supportsTray) createTray() if (!err) createTray()
}) })
} }
@@ -55,10 +55,14 @@ function checkLinuxTraySupport (cb) {
// libappindicator1. If WebTorrent was installed from the deb file, we should // libappindicator1. If WebTorrent was installed from the deb file, we should
// always have it. If it was installed from the zip file, we might not. // always have it. If it was installed from the zip file, we might not.
cp.exec('dpkg --get-selections libappindicator1', function (err, stdout) { cp.exec('dpkg --get-selections libappindicator1', function (err, stdout) {
if (err) return cb(false) if (err) return cb(err)
// Unfortunately there's no cleaner way, as far as I can tell, to check // Unfortunately there's no cleaner way, as far as I can tell, to check
// whether a debian package is installed: // whether a debian package is installed:
cb(stdout.endsWith('\tinstall\n')) if (stdout.endsWith('\tinstall\n')) {
cb(null)
} else {
cb(new Error('debian package not installed'))
}
}) })
} }

View File

@@ -281,7 +281,7 @@ module.exports = class TorrentListController {
// Recursively finds {name, path, size} for all files in a folder // Recursively finds {name, path, size} for all files in a folder
// Calls `cb` on success, calls `onError` on failure // Calls `cb` on success, calls `onError` on failure
function findFilesRecursive (paths, cb) { function findFilesRecursive (paths, cb_) {
if (paths.length > 1) { if (paths.length > 1) {
let numComplete = 0 let numComplete = 0
let ret = [] let ret = []
@@ -290,7 +290,7 @@ function findFilesRecursive (paths, cb) {
ret.push(...fileObjs) ret.push(...fileObjs)
if (++numComplete === paths.length) { if (++numComplete === paths.length) {
ret.sort((a, b) => a.path < b.path ? -1 : a.path > b.path) ret.sort((a, b) => a.path < b.path ? -1 : a.path > b.path)
cb(ret) cb_(ret)
} }
}) })
}) })
@@ -304,7 +304,7 @@ function findFilesRecursive (paths, cb) {
// Files: return name, path, and size // Files: return name, path, and size
if (!stat.isDirectory()) { if (!stat.isDirectory()) {
const filePath = fileOrFolder const filePath = fileOrFolder
return cb([{ return cb_([{
name: path.basename(filePath), name: path.basename(filePath),
path: filePath, path: filePath,
size: stat.size size: stat.size
@@ -316,7 +316,7 @@ function findFilesRecursive (paths, cb) {
fs.readdir(folderPath, function (err, fileNames) { fs.readdir(folderPath, function (err, fileNames) {
if (err) return dispatch('error', err) if (err) return dispatch('error', err)
const paths = fileNames.map((fileName) => path.join(folderPath, fileName)) const paths = fileNames.map((fileName) => path.join(folderPath, fileName))
findFilesRecursive(paths, cb) findFilesRecursive(paths, cb_)
}) })
}) })
} }