From c764bf48841beb63c8820b3aaf568d3f0852ac75 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 1 Mar 2017 23:07:10 -0800 Subject: [PATCH] fixes for standard v10 --- src/main/external-player.js | 4 ++-- src/main/ipc.js | 4 ++-- src/main/tray.js | 12 ++++++++---- src/renderer/controllers/torrent-list-controller.js | 8 ++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/external-player.js b/src/main/external-player.js index 45f655e2..39b80061 100644 --- a/src/main/external-player.js +++ b/src/main/external-player.js @@ -17,8 +17,8 @@ let proc = null function checkInstall (playerPath, cb) { // check for VLC if external player has not been specified by the user // otherwise assume the player is installed - if (playerPath == null) return vlcCommand((err) => cb(!err)) - process.nextTick(() => cb(true)) + if (playerPath == null) return vlcCommand(cb) + process.nextTick(() => cb(null)) } function spawn (playerPath, url, title) { diff --git a/src/main/ipc.js b/src/main/ipc.js index 6728ff3d..e6110626 100644 --- a/src/main/ipc.js +++ b/src/main/ipc.js @@ -166,8 +166,8 @@ function init () { ipc.on('checkForExternalPlayer', function (e, path) { const externalPlayer = require('./external-player') - externalPlayer.checkInstall(path, function (isInstalled) { - windows.main.send('checkForExternalPlayer', isInstalled) + externalPlayer.checkInstall(path, function (err) { + windows.main.send('checkForExternalPlayer', !err) }) }) diff --git a/src/main/tray.js b/src/main/tray.js index e0395723..889d1c86 100644 --- a/src/main/tray.js +++ b/src/main/tray.js @@ -36,8 +36,8 @@ function setWindowFocus (flag) { } function initLinux () { - checkLinuxTraySupport(function (supportsTray) { - if (supportsTray) createTray() + checkLinuxTraySupport(function (err) { + if (!err) createTray() }) } @@ -55,10 +55,14 @@ function checkLinuxTraySupport (cb) { // 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. 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 // 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')) + } }) } diff --git a/src/renderer/controllers/torrent-list-controller.js b/src/renderer/controllers/torrent-list-controller.js index aabf1522..0360214c 100644 --- a/src/renderer/controllers/torrent-list-controller.js +++ b/src/renderer/controllers/torrent-list-controller.js @@ -281,7 +281,7 @@ module.exports = class TorrentListController { // Recursively finds {name, path, size} for all files in a folder // Calls `cb` on success, calls `onError` on failure -function findFilesRecursive (paths, cb) { +function findFilesRecursive (paths, cb_) { if (paths.length > 1) { let numComplete = 0 let ret = [] @@ -290,7 +290,7 @@ function findFilesRecursive (paths, cb) { ret.push(...fileObjs) if (++numComplete === paths.length) { 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 if (!stat.isDirectory()) { const filePath = fileOrFolder - return cb([{ + return cb_([{ name: path.basename(filePath), path: filePath, size: stat.size @@ -316,7 +316,7 @@ function findFilesRecursive (paths, cb) { fs.readdir(folderPath, function (err, fileNames) { if (err) return dispatch('error', err) const paths = fileNames.map((fileName) => path.join(folderPath, fileName)) - findFilesRecursive(paths, cb) + findFilesRecursive(paths, cb_) }) }) }