mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
Centralized creation of writers in the HTML exporter and added some logging. This could help with #16.
This commit is contained in:
parent
2ccb0cea9f
commit
42fabf7b1c
@ -87,7 +87,7 @@ public class HTMLExporter {
|
|||||||
|
|
||||||
MustacheFactory mf = new DefaultMustacheFactory();
|
MustacheFactory mf = new DefaultMustacheFactory();
|
||||||
Mustache mustache = mf.compile("templates/html/index.mustache");
|
Mustache mustache = mf.compile("templates/html/index.mustache");
|
||||||
OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(base + "index.html"), Charset.forName("UTF-8").newEncoder());
|
OutputStreamWriter w = getWriter(base + "index.html");
|
||||||
mustache.execute(w, scope);
|
mustache.execute(w, scope);
|
||||||
w.close();
|
w.close();
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class HTMLExporter {
|
|||||||
scope.putAll(db.getMessageTypesWithCount(d));
|
scope.putAll(db.getMessageTypesWithCount(d));
|
||||||
scope.putAll(db.getMessageMediaTypesWithCount(d));
|
scope.putAll(db.getMessageMediaTypesWithCount(d));
|
||||||
|
|
||||||
w = new OutputStreamWriter(new FileOutputStream(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html"), Charset.forName("UTF-8").newEncoder());
|
w = getWriter(base + "dialogs" + File.separatorChar + "user_" + d.id + ".html");
|
||||||
mustache.execute(w, scope);
|
mustache.execute(w, scope);
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public class HTMLExporter {
|
|||||||
scope.putAll(db.getMessageTypesWithCount(c));
|
scope.putAll(db.getMessageTypesWithCount(c));
|
||||||
scope.putAll(db.getMessageMediaTypesWithCount(c));
|
scope.putAll(db.getMessageMediaTypesWithCount(c));
|
||||||
|
|
||||||
w = new OutputStreamWriter(new FileOutputStream(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html"), Charset.forName("UTF-8").newEncoder());
|
w = getWriter(base + "dialogs" + File.separatorChar + "chat_" + c.id + ".html");
|
||||||
mustache.execute(w, scope);
|
mustache.execute(w, scope);
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
@ -139,6 +139,11 @@ public class HTMLExporter {
|
|||||||
throw new RuntimeException("Exception above!");
|
throw new RuntimeException("Exception above!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OutputStreamWriter getWriter(String filename) {
|
||||||
|
logger.trace("Creating writer for file {}", filename);
|
||||||
|
return new OutputStreamWriter(new FileOutputStream(filename), Charset.forName("UTF-8").newEncoder());
|
||||||
|
}
|
||||||
|
|
||||||
private String intArrayToString(int[][] data) {
|
private String intArrayToString(int[][] data) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Loading…
Reference in New Issue
Block a user