From 9bee01698fa19bcfe89e18e891e7cb89c11161a9 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 13 Dec 2017 19:03:32 +0100 Subject: [PATCH] HTML export now shows some progress information. --- .../telegram_backup/exporter/HTMLExporter.kt | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/de/fabianonline/telegram_backup/exporter/HTMLExporter.kt b/src/main/kotlin/de/fabianonline/telegram_backup/exporter/HTMLExporter.kt index b57d184..2e688df 100644 --- a/src/main/kotlin/de/fabianonline/telegram_backup/exporter/HTMLExporter.kt +++ b/src/main/kotlin/de/fabianonline/telegram_backup/exporter/HTMLExporter.kt @@ -61,7 +61,7 @@ class HTMLExporter { val chats = db.getListOfChatsForExport() logger.trace("Got {} chats", chats.size) - logger.debug("Generating index.html") + println("Generating index.html...") val scope = HashMap() scope.put("user", user) scope.put("dialogs", dialogs) @@ -97,7 +97,7 @@ class HTMLExporter { mustache = mf.compile("templates/html/chat.mustache") var i = 0 - logger.debug("Generating {} dialog pages", dialogs.size) + println("Generating ${dialogs.size} dialog pages...") for (d in dialogs) { i++ logger.trace("Dialog {}/{}: {}", i, dialogs.size, Utils.anonymize("" + d.id)) @@ -115,10 +115,15 @@ class HTMLExporter { w = getWriter(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html") mustache.execute(w, scope) w.close() + print(".") + if (i % 100 == 0) { + println(" - $i/${dialogs.size}") + } } + println() i = 0 - logger.debug("Generating {} chat pages", chats.size) + println("Generating ${chats.size} chat pages...") for (c in chats) { i++ logger.trace("Chat {}/{}: {}", i, chats.size, Utils.anonymize("" + c.id)) @@ -136,14 +141,19 @@ class HTMLExporter { w = getWriter(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html") mustache.execute(w, scope) w.close() + print(".") + if (i % 100 == 0) { + println(" - $i/${chats.size}") + } } + println() - logger.debug("Generating additional files") + println("Generating additional files...") // Copy CSS val cssFile = javaClass.getResource("/templates/html/style.css") val dest = File(base + "style.css") FileUtils.copyURLToFile(cssFile, dest) - logger.debug("Done exporting.") + println("Finished.") } catch (e: IOException) { e.printStackTrace() logger.error("Caught an exception!", e)