Fix: Speicheranzeige Dateien - sinnvolle Werte statt falscher Disk-Info
This commit is contained in:
@@ -199,18 +199,10 @@ router.post('/', authenticate, (req, res) => {
|
||||
router.get('/storage', authenticate, (req, res) => {
|
||||
const uid = req.user.id;
|
||||
const used = db.prepare('SELECT COALESCE(SUM(size),0) AS s FROM files WHERE user_id=?').get(uid).s;
|
||||
const maxMb = parseInt(getSetting('file_max_size_mb') || '50');
|
||||
const maxCount = parseInt(getSetting('file_max_count') || '20');
|
||||
const max = maxMb * maxCount * 1024 * 1024;
|
||||
let diskFree = null;
|
||||
try {
|
||||
const { execSync } = require('child_process');
|
||||
const out = execSync(`df -k "${process.env.UPLOAD_DIR || '/data/uploads'}"`, { timeout:3000 }).toString();
|
||||
const line = out.trim().split('\n').pop();
|
||||
const parts = line.trim().split(/\s+/);
|
||||
if (parts[3]) diskFree = parseInt(parts[3]) * 1024;
|
||||
} catch {}
|
||||
res.json({ used, max, diskFree });
|
||||
const count = db.prepare('SELECT COUNT(*) AS c FROM files WHERE user_id=?').get(uid).c;
|
||||
const maxSizeMb = parseInt(getSetting('file_max_size_mb') || '50');
|
||||
const maxCount = parseInt(getSetting('file_max_count') || '20');
|
||||
res.json({ used, count, maxSizeMb, maxCount });
|
||||
});
|
||||
|
||||
router.get('/:id/download', authenticate, async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user