diff --git a/package.json b/package.json index b7141c6f..39965e89 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "dependencies": { "airplay-js": "guerrerocarlos/node-airplay-js", "application-config": "^0.2.1", - "async": "^2.0.0-rc.5", "bitfield": "^1.0.2", "chromecasts": "^1.8.0", "concat-stream": "^1.5.1", @@ -34,6 +33,7 @@ "musicmetadata": "^2.0.2", "network-address": "^1.1.0", "prettier-bytes": "^1.0.1", + "run-parallel": "^1.1.6", "simple-get": "^2.0.0", "srt-to-vtt": "^1.1.1", "virtual-dom": "^2.1.1", diff --git a/renderer/index.js b/renderer/index.js index 56ae762a..db603af6 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -14,7 +14,7 @@ var ipcRenderer = electron.ipcRenderer setupIpc() var appConfig = require('application-config')('WebTorrent') -var Async = require('async') +var parallel = require('run-parallel') var concat = require('concat-stream') var dragDrop = require('drag-drop') var fs = require('fs-extra') @@ -606,22 +606,23 @@ function addSubtitles (files, autoSelect) { if (state.playing.type !== 'video') return // Read the files concurrently, then add all resulting subtitle tracks - console.log(files) - var subs = state.playing.subtitles - Async.map(files, loadSubtitle, function (err, tracks) { + var jobs = files.map((file) => (cb) => loadSubtitle(file, cb)) + parallel(jobs, function (err, tracks) { if (err) return onError(err) for (var i = 0; i < tracks.length; i++) { // No dupes allowed var track = tracks[i] - if (subs.tracks.some((t) => track.filePath === t.filePath)) continue + if (state.playing.subtitles.tracks.some( + (t) => track.filePath === t.filePath)) continue // Add the track - subs.tracks.push(track) + state.playing.subtitles.tracks.push(track) // If we're auto-selecting a track, try to find one in the user's language if (autoSelect && (i === 0 || isSystemLanguage(track.language))) { - state.playing.subtitles.selectedIndex = subs.tracks.length - 1 + state.playing.subtitles.selectedIndex = + state.playing.subtitles.tracks.length - 1 } } diff --git a/renderer/webtorrent.js b/renderer/webtorrent.js index 19612fed..3563c3e4 100644 --- a/renderer/webtorrent.js +++ b/renderer/webtorrent.js @@ -349,10 +349,6 @@ function selectFiles (torrentOrInfoHash, selections) { } else { console.log('deselecting file ' + i + ' of torrent ' + torrent.name) file.deselect() - - // If we deselected a file, try to nuke it to save disk space - var filePath = path.join(torrent.path, file.path) - fs.unlink(filePath) // Ignore errors for now } } }