From c06fce3007166b790e83ff775a8526004857bef7 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Fri, 14 Feb 2020 11:43:50 +0000 Subject: [PATCH] Bugfix: looking in the wrong directory for uploads. --- resources/templates/base.html | 4 +++- src/smeagol/routes/wiki.clj | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/resources/templates/base.html b/resources/templates/base.html index 7a31f07..01152af 100644 --- a/resources/templates/base.html +++ b/resources/templates/base.html @@ -46,7 +46,9 @@

{% i18n site-title %}: {{title}}

- {{header|safe}} + {% if message %}

{{message}}

diff --git a/src/smeagol/routes/wiki.clj b/src/smeagol/routes/wiki.clj index e33cbdc..c87dbef 100644 --- a/src/smeagol/routes/wiki.clj +++ b/src/smeagol/routes/wiki.clj @@ -15,6 +15,7 @@ [noir.util.route :as route] [noir.session :as session] [smeagol.authenticate :as auth] + [smeagol.configuration :refer [config]] [smeagol.diff2html :as d2h] [smeagol.formatting :refer [md->html]] [smeagol.history :as hist] @@ -187,7 +188,6 @@ [request] (let [params (keywordize-keys (:params request)) - data-path (str util/content-dir "/uploads/") cl (count (io/resource-path)) files (map @@ -202,11 +202,19 @@ (fs/mod-time %) (format-instant (fs/mod-time %))) (fs/name %) - (subs (str (fs/absolute %)) cl)]) + (try + (subs (str (fs/absolute %)) cl) + (catch StringIndexOutOfBoundsException x + (log/error "Could not resolve relative path for" % + ";\n resource-path is:" (io/resource-path) + ";\n absolute path is:" (fs/absolute %) + ";\n data-path is:" util/upload-dir + ";\n content path is:" (:content-dir config)) + %))]) (remove #(or (cs/starts-with? (fs/name %) ".") (fs/directory? %)) - (file-seq (clojure.java.io/file data-path))))] + (file-seq (clojure.java.io/file util/upload-dir))))] (log/info (with-out-str (pprint files))) (layout/render "list-uploads.html"