Create Torrent: exclude .DS_Store, fix drag-drop
This commit is contained in:
@@ -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
|
||||
}])
|
||||
}
|
||||
|
||||
|
||||
@@ -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)}`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user