feat: add database details section to settings

Shows path to database (click to copy), database size, database log
size, message count.

Also adds a Ctrl+Shift button to wipe the database permanently. This is
performed by clearing the Messages collection and then rebuilding the
database, which brings it down to around 48KB on my machine (even with
many messages).
This commit is contained in:
Dean Sheather
2024-04-11 18:46:26 +10:00
parent 8b7a671e52
commit 715fb7aa5b
7 changed files with 265 additions and 15 deletions
+12
View File
@@ -10,4 +10,16 @@ internal static class StringUtil {
bytes[^1] = 0;
return bytes;
}
// Taken from https://stackoverflow.com/a/4975942
internal static String BytesToString(long byteCount) {
string[] suf = ["B", "KB", "MB", "GB", "TB", "PB", "EB"]; // Longs run out around EB
if (byteCount == 0)
return "0" + suf[0];
var bytes = Math.Abs(byteCount);
var place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
var num = Math.Round(bytes / Math.Pow(1024, place), 1);
return (Math.Sign(byteCount) * num).ToString("N0") + suf[place];
}
}