From c1a59b7e9bfc45d44322d92b7a397fde29f98a1e Mon Sep 17 00:00:00 2001 From: simon987 Date: Tue, 24 Apr 2018 16:59:16 -0400 Subject: [PATCH] Documents no longer duplicated when indexing twice in a row. Thumbnails and documents erased when directory is removed --- crawler.py | 2 ++ run.py | 4 ++++ static/js/search.js | 16 ++++++++-------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/crawler.py b/crawler.py index d6fe673..ff425d8 100644 --- a/crawler.py +++ b/crawler.py @@ -124,6 +124,8 @@ class TaskManager: def execute_crawl(self, directory: Directory, counter: Value, done: Value): + Search("changeme").delete_directory(directory.id) + chksum_calcs = [] for arg in directory.get_option("CheckSumCalculators").split(","): diff --git a/run.py b/run.py index 9c4a1ca..4bfa00f 100644 --- a/run.py +++ b/run.py @@ -296,6 +296,10 @@ def directory_update_opt(dir_id): @app.route("/directory//del") def directory_del(dir_id): + search.delete_directory(dir_id) + if os.path.exists("static/thumbnails/" + str(dir_id)): + shutil.rmtree("static/thumbnails/" + str(dir_id)) + storage.remove_directory(dir_id) flash("Deleted directory", "success") diff --git a/static/js/search.js b/static/js/search.js index 359df57..8e9d2bd 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -276,15 +276,15 @@ function createDocCard(hit) { break; case "video": - thumbnailOverlay = document.createElement("div"); - thumbnailOverlay.setAttribute("class", "card-img-overlay"); - //Duration - let durationBadge = document.createElement("span"); - durationBadge.setAttribute("class", "badge badge-resolution"); - durationBadge.appendChild(document.createTextNode(humanTime(hit["_source"]["duration"]))); - thumbnailOverlay.appendChild(durationBadge); - + if (hit["_source"].hasOwnProperty("duration")) { + thumbnailOverlay = document.createElement("div"); + thumbnailOverlay.setAttribute("class", "card-img-overlay"); + let durationBadge = document.createElement("span"); + durationBadge.setAttribute("class", "badge badge-resolution"); + durationBadge.appendChild(document.createTextNode(humanTime(hit["_source"]["duration"]))); + thumbnailOverlay.appendChild(durationBadge); + } } //Tags