Fix: Speicheranzeige Dateien - sinnvolle Werte statt falscher Disk-Info

This commit is contained in:
2026-05-28 12:20:28 +02:00
parent 7182431ce7
commit c6542128f9
2 changed files with 15 additions and 25 deletions

View File

@@ -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 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');
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 });
res.json({ used, count, maxSizeMb, maxCount });
});
router.get('/:id/download', authenticate, async (req, res) => {

View File

@@ -280,24 +280,22 @@ export default function Dateien({ toast, mobile }) {
<ConfirmDialog/>
{/* ── Speicherplatz ─────────────────────────────────────────────────── */}
{storage && (
<div style={{marginBottom:14}}>
<div style={{display:'flex',justifyContent:'space-between',
color:'rgba(255,255,255,0.35)',fontFamily:'monospace',fontSize:9,marginBottom:4}}>
<span>{fmtSize(storage.used)} belegt</span>
<span>{storage.diskFree!=null ? `${fmtSize(storage.diskFree)} frei auf Disk` : ''}</span>
<div style={{marginBottom:14,padding:'10px 12px',background:'rgba(255,255,255,0.02)',
border:'1px solid rgba(255,255,255,0.06)',borderRadius:8}}>
<div style={{display:'flex',justifyContent:'space-between',alignItems:'center',
color:'rgba(255,255,255,0.45)',fontFamily:'monospace',fontSize:10}}>
<span>{fmtSize(storage.used)} belegt · {storage.count}/{storage.maxCount} Dateien</span>
<span style={{fontSize:9,color:'rgba(255,255,255,0.25)'}}>max. {storage.maxSizeMb} MB pro Datei</span>
</div>
<div style={{height:4,borderRadius:4,background:'rgba(255,255,255,0.06)',overflow:'hidden'}}>
<div style={{height:3,borderRadius:3,background:'rgba(255,255,255,0.06)',overflow:'hidden',marginTop:7}}>
<div style={{
height:'100%', borderRadius:4,
width:`${Math.min(100,(storage.used/storage.max)*100)}%`,
background: storage.used/storage.max > 0.85 ? '#ff6b9d' :
storage.used/storage.max > 0.6 ? '#ffe66d' : '#4ecdc4',
height:'100%', borderRadius:3,
width:`${Math.min(100,(storage.count/storage.maxCount)*100)}%`,
background: storage.count/storage.maxCount > 0.85 ? '#ff6b9d' :
storage.count/storage.maxCount > 0.6 ? '#ffe66d' : '#4ecdc4',
transition:'width 0.4s',
}}/>
</div>
<div style={{color:'rgba(255,255,255,0.2)',fontFamily:'monospace',fontSize:8,marginTop:3,textAlign:'right'}}>
Limit: {fmtSize(storage.max)}
</div>
</div>
)}
{shareItem && <ShareModal item={shareItem.item} type={shareItem.type} onClose={()=>{setShareItem(null);load();}} toast={toast}/>}