@@ -33,7 +33,6 @@ function CreateTorrentPage (state) {
|
|||||||
|
|
||||||
// Sanity check: show the number of files and total size
|
// Sanity check: show the number of files and total size
|
||||||
var numFiles = files.length
|
var numFiles = files.length
|
||||||
console.log('FILES', files)
|
|
||||||
var totalBytes = files
|
var totalBytes = files
|
||||||
.map((f) => f.size)
|
.map((f) => f.size)
|
||||||
.reduce((a, b) => a + b, 0)
|
.reduce((a, b) => a + b, 0)
|
||||||
@@ -41,10 +40,16 @@ function CreateTorrentPage (state) {
|
|||||||
|
|
||||||
// Then, use the name of the base folder (or sole file, for a single file torrent)
|
// Then, use the name of the base folder (or sole file, for a single file torrent)
|
||||||
// as the default name. Show all files relative to the base folder.
|
// as the default name. Show all files relative to the base folder.
|
||||||
var defaultName = files.length === 1
|
var defaultName, basePath
|
||||||
? files[0].name
|
if (files.length === 1) {
|
||||||
: path.basename(pathPrefix)
|
// Single file torrent: /a/b/foo.jpg -> torrent name "foo.jpg", path "/a/b"
|
||||||
var basePath = path.dirname(pathPrefix)
|
defaultName = files[0].name
|
||||||
|
basePath = pathPrefix
|
||||||
|
} else {
|
||||||
|
// Multi file torrent: /a/b/{foo, bar}.jpg -> torrent name "b", path "/a"
|
||||||
|
defaultName = files[0].name
|
||||||
|
basePath = path.basename(pathPrefix)
|
||||||
|
}
|
||||||
var maxFileElems = 100
|
var maxFileElems = 100
|
||||||
var fileElems = files.slice(0, maxFileElems).map(function (file) {
|
var fileElems = files.slice(0, maxFileElems).map(function (file) {
|
||||||
var relativePath = files.length === 0 ? file.name : path.relative(pathPrefix, file.path)
|
var relativePath = files.length === 0 ? file.name : path.relative(pathPrefix, file.path)
|
||||||
|
|||||||
Reference in New Issue
Block a user