From 439e2841351220c21f9cdd0dfc1b0074c51796f0 Mon Sep 17 00:00:00 2001 From: sqozz Date: Mon, 2 Apr 2018 02:52:05 +0200 Subject: [PATCH] Add torrent file detection for single files --- static/js/create.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/static/js/create.js b/static/js/create.js index 175c658..421cbd3 100644 --- a/static/js/create.js +++ b/static/js/create.js @@ -56,13 +56,16 @@ function fillDetectedFilelist(file) { filesGroup = document.querySelectorAll(".filesGroup")[0] if(torrentObject["info"]["files"] != undefined && torrentObject["info"]["files"].length > 0) { + // render the file-tree if multiple files are present autodetectSuccess = true - rootElement = document.createElement("div") for(var fileIndex = 0; fileIndex < torrentObject.info.files.length; fileIndex++){ path = torrentObject["info"]["files"][fileIndex]["path"] 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]