From 3d4d1c8650bd4679a977bcdf9f07166838d0270f Mon Sep 17 00:00:00 2001 From: DC Date: Wed, 27 Apr 2016 03:21:14 -0700 Subject: [PATCH] Create Torrent: exclude .DS_Store, fix drag-drop --- renderer/index.js | 4 ++-- renderer/views/create-torrent-page.js | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/renderer/index.js b/renderer/index.js index fb641990..a7544ff9 100644 --- a/renderer/index.js +++ b/renderer/index.js @@ -647,7 +647,7 @@ function showCreateTorrent (files) { findFilesRecursive(fileOrFolder, showCreateTorrent) } -// Recursively finds {name, length, path} 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 function findFilesRecursive (fileOrFolder, cb) { fs.stat(fileOrFolder, function (err, stat) { @@ -659,7 +659,7 @@ function findFilesRecursive (fileOrFolder, cb) { return cb([{ name: path.basename(filePath), path: filePath, - length: stat.size + size: stat.size }]) } diff --git a/renderer/views/create-torrent-page.js b/renderer/views/create-torrent-page.js index a6ef0fab..68b98490 100644 --- a/renderer/views/create-torrent-page.js +++ b/renderer/views/create-torrent-page.js @@ -13,8 +13,12 @@ var {dispatch} = require('../lib/dispatcher') function CreateTorrentPage (state) { var info = state.location.current() - // First, extract the base folder that the files are all in + // Preprocess: exclude .DS_Store and other dotfiles var files = info.files + .filter((f) => !f.name.startsWith('.')) + .map((f) => ({name: f.name, path: f.path, size: f.size})) + + // First, extract the base folder that the files are all in var pathPrefix = info.folderPath if (!pathPrefix) { if (files.length > 0) { @@ -29,8 +33,9 @@ function CreateTorrentPage (state) { // Sanity check: show the number of files and total size var numFiles = files.length + console.log('FILES', files) var totalBytes = files - .map((f) => f.length) + .map((f) => f.size) .reduce((a, b) => a + b, 0) var torrentInfo = `${numFiles} files, ${prettyBytes(totalBytes)}`