Add torrent file detection for single files

This commit is contained in:
sqozz 2018-04-02 02:52:05 +02:00
parent b56fe04bbe
commit 439e284135

View File

@ -56,13 +56,16 @@ function fillDetectedFilelist(file) {
filesGroup = document.querySelectorAll(".filesGroup")[0] filesGroup = document.querySelectorAll(".filesGroup")[0]
if(torrentObject["info"]["files"] != undefined && torrentObject["info"]["files"].length > 0) { if(torrentObject["info"]["files"] != undefined && torrentObject["info"]["files"].length > 0) {
// render the file-tree if multiple files are present
autodetectSuccess = true autodetectSuccess = true
rootElement = document.createElement("div")
for(var fileIndex = 0; fileIndex < torrentObject.info.files.length; fileIndex++){ for(var fileIndex = 0; fileIndex < torrentObject.info.files.length; fileIndex++){
path = torrentObject["info"]["files"][fileIndex]["path"] path = torrentObject["info"]["files"][fileIndex]["path"]
renderFile(getRoot(), path.reverse()) renderFile(getRoot(), path.reverse())
} }
} else {
// assume the torrent is only one file named "name"
autodetectSuccess = true
renderFile(getRoot(), [torrentObject["info"]["name"]])
} }
var detectInfosGroup = document.querySelectorAll(".detectedInfosGroup")[0] var detectInfosGroup = document.querySelectorAll(".detectedInfosGroup")[0]