Fehlerbehebung Dateien und Smilies in Nachrichten
This commit is contained in:
@@ -196,6 +196,23 @@ 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 });
|
||||
});
|
||||
|
||||
router.get('/:id/download', authenticate, async (req, res) => {
|
||||
const uid = req.user.id;
|
||||
const file = db.prepare('SELECT * FROM files WHERE id=?').get(req.params.id);
|
||||
@@ -279,22 +296,6 @@ router.delete('/:id/share/:userId', authenticate, (req, res) => {
|
||||
res.json({ success: true });
|
||||
});
|
||||
|
||||
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 max = parseInt(getSetting('file_max_size_mb') || '50') *
|
||||
parseInt(getSetting('file_max_count') || '20') * 1024 * 1024;
|
||||
// Disk space via Node
|
||||
const { execSync } = require('child_process');
|
||||
let diskFree = null;
|
||||
try {
|
||||
const out = execSync(`df -k "${process.env.UPLOAD_DIR || '/data/uploads'}" | tail -1`).toString();
|
||||
const parts = out.trim().split(/\s+/);
|
||||
diskFree = parseInt(parts[3]) * 1024; // available bytes
|
||||
} catch {}
|
||||
res.json({ used, max, diskFree });
|
||||
});
|
||||
|
||||
// Settings
|
||||
router.get('/settings', authenticate, requireAdmin, (req, res) => {
|
||||
const s = db.prepare('SELECT * FROM admin_settings').all();
|
||||
|
||||
Reference in New Issue
Block a user