add total file size stat for ranking page
This commit is contained in:
@@ -445,6 +445,7 @@
|
||||
"stat_deleted": "Gelöscht",
|
||||
"stat_comments": "Gesamt Kommentare",
|
||||
"stat_favs": "Gesamt Favoriten",
|
||||
"stat_disk_usage": "Dateigröße Gesamt",
|
||||
"most_favorited": "Meiste Favs",
|
||||
"favs": "Favs",
|
||||
"top_xd": "Top xD-Score"
|
||||
|
||||
@@ -449,6 +449,7 @@
|
||||
"stat_deleted": "Deleted",
|
||||
"stat_comments": "Total Comments",
|
||||
"stat_favs": "Total Favorites",
|
||||
"stat_disk_usage": "Total File Size",
|
||||
"most_favorited": "Most Favorited",
|
||||
"favs": "favs",
|
||||
"top_xd": "Top xD Scores"
|
||||
|
||||
@@ -445,6 +445,7 @@
|
||||
"stat_deleted": "Verwijderd",
|
||||
"stat_comments": "Totaal aantal reacties",
|
||||
"stat_favs": "Totaal aantal favorieten",
|
||||
"stat_disk_usage": "Totale Bestandsgrootte",
|
||||
"most_favorited": "Meest Gefavoriet",
|
||||
"favs": "favorieten",
|
||||
"top_xd": "Top xD-scores"
|
||||
|
||||
@@ -448,6 +448,7 @@
|
||||
"stat_deleted": "Gelöscht",
|
||||
"stat_comments": "Gesamtanzahl Kommentare",
|
||||
"stat_favs": "Gesamtanzahl Favoriten",
|
||||
"stat_disk_usage": "Dateigröße Gesamt",
|
||||
"most_favorited": "Am häufigsten favorisiert",
|
||||
"favs": "Favoriten",
|
||||
"top_xd": "Beste xD-Punktestände"
|
||||
|
||||
@@ -3,6 +3,32 @@ import lib from "../lib.mjs";
|
||||
import config from "../config.mjs";
|
||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||
import fetch from "flumm-fetch";
|
||||
import { exec } from "child_process";
|
||||
|
||||
let cachedDiskSize = "Calculating...";
|
||||
|
||||
function updateDiskSize() {
|
||||
exec("du -sb f0ckm-data/b f0ckm-data/t f0ckm-data/c", (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error calculating disk size: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
const lines = stdout.trim().split('\n');
|
||||
let totalBytes = 0;
|
||||
for (const line of lines) {
|
||||
const match = line.match(/^(\d+)\s+/);
|
||||
if (match) {
|
||||
totalBytes += parseInt(match[1], 10);
|
||||
}
|
||||
}
|
||||
cachedDiskSize = lib.formatSize(totalBytes);
|
||||
});
|
||||
}
|
||||
|
||||
// Update every 30 minutes
|
||||
setInterval(updateDiskSize, 1000 * 60 * 30);
|
||||
updateDiskSize(); // Run once at start
|
||||
|
||||
|
||||
export default (router, tpl) => {
|
||||
router.get(/^\/ranking$/, lib.loggedin, async (req, res) => {
|
||||
@@ -94,6 +120,7 @@ export default (router, tpl) => {
|
||||
totalComments,
|
||||
totalFavs,
|
||||
enable_nsfl: config.enable_nsfl,
|
||||
diskSize: cachedDiskSize,
|
||||
tmp: null,
|
||||
session: (req.session && req.session.user) ? { ...req.session } : false,
|
||||
page_meta: {
|
||||
|
||||
Reference in New Issue
Block a user