feat: Speicherplatz-Warnung hinzugefügt und Versionsnummer auf 1.0.71 erhöht
This commit is contained in:
46
app.py
46
app.py
@@ -82,6 +82,8 @@ copy_state = {
|
||||
'bytes_total': 0, 'bytes_done': 0,
|
||||
'start_ts': None, 'eta_sec': None, 'speed_bps': 0,
|
||||
'phase': 'idle',
|
||||
'space_warning': False, 'space_needed': 0, 'space_free': 0,
|
||||
'last_success_file': '',
|
||||
}
|
||||
copy_lock = threading.Lock()
|
||||
_copy_thread: threading.Thread | None = None
|
||||
@@ -832,7 +834,9 @@ def do_copy(src_devs, dst_dev, cfg):
|
||||
done=0, total=0, logs=[], current='',
|
||||
bytes_total=0, bytes_done=0,
|
||||
start_ts=time.time(), eta_sec=None, speed_bps=0,
|
||||
phase='copy')
|
||||
phase='copy',
|
||||
space_warning=False, space_needed=0, space_free=0,
|
||||
last_success_file='')
|
||||
save_state()
|
||||
n = len(src_devs)
|
||||
add_log(f'Kopiervorgang gestartet ({n} Quelle{"n" if n != 1 else ""})')
|
||||
@@ -898,6 +902,23 @@ def do_copy(src_devs, dst_dev, cfg):
|
||||
copy_state['total'] = total
|
||||
copy_state['bytes_total'] = bytes_total
|
||||
add_log(f'{total} Dateien gesamt ({_fmt_bytes(bytes_total)})')
|
||||
|
||||
# -- Speicherplatz-Prüfung ------------------------------------------
|
||||
try:
|
||||
dst_free = shutil.disk_usage(dst_mp).free
|
||||
except Exception:
|
||||
dst_free = 0
|
||||
if bytes_total > 0 and dst_free < bytes_total:
|
||||
with copy_lock:
|
||||
copy_state.update(space_warning=True,
|
||||
space_needed=bytes_total,
|
||||
space_free=dst_free)
|
||||
add_log(
|
||||
f'⚠ Nicht genug Speicherplatz! '
|
||||
f'Benötigt: {_fmt_bytes(bytes_total)}, '
|
||||
f'Verfügbar: {_fmt_bytes(dst_free)} – '
|
||||
f'Quelle wird nicht gelöscht'
|
||||
)
|
||||
save_state()
|
||||
|
||||
# -- Phase 1: Kopieren (alle Quellen) --------------------------------
|
||||
@@ -963,6 +984,7 @@ def do_copy(src_devs, dst_dev, cfg):
|
||||
|
||||
with copy_lock:
|
||||
copy_state['bytes_done'] += fsize
|
||||
copy_state['last_success_file'] = str(dst_f)
|
||||
bd = copy_state['bytes_done']
|
||||
bt = copy_state['bytes_total']
|
||||
elapsed = time.time() - copy_state['start_ts']
|
||||
@@ -1018,7 +1040,11 @@ def do_copy(src_devs, dst_dev, cfg):
|
||||
|
||||
# -- Phase 3: Quelle löschen ----------------------------------------
|
||||
if cfg.get('delete_source') and verified_pairs:
|
||||
if verify_errors:
|
||||
with copy_lock:
|
||||
_space_warn = copy_state.get('space_warning', False)
|
||||
if _space_warn:
|
||||
add_log('Quelldateien NICHT gelöscht (Speicherplatz unzureichend)')
|
||||
elif verify_errors:
|
||||
add_log('Quelldateien NICHT gelöscht (Prüfsummenfehler)')
|
||||
else:
|
||||
with copy_lock:
|
||||
@@ -2920,6 +2946,10 @@ body{background:var(--bg);color:var(--txt);font-family:-apple-system,BlinkMacSys
|
||||
</div>
|
||||
<div class="card-body" style="padding:.65rem .85rem">
|
||||
<div id="log-box" class="log-wrap"><div class="expl-empty">Noch keine Einträge</div></div>
|
||||
<div id="space-warn-box" style="display:none;margin-top:.6rem;padding:.55rem .75rem;background:rgba(251,191,36,.08);border:1px solid rgba(251,191,36,.4);border-radius:.45rem">
|
||||
<div style="font-size:.82rem;font-weight:700;color:var(--ylw)">⚠ Nicht genug Speicherplatz</div>
|
||||
<div id="space-warn-detail" style="font-size:.76rem;color:var(--sub);margin-top:.25rem;line-height:1.5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3680,6 +3710,18 @@ async function poll(){
|
||||
// Log
|
||||
if(c.logs&&c.logs.length)
|
||||
$('log-box').innerHTML=c.logs.slice().reverse().map(l=>`<div class="log-row"><span class="log-t">${l.t}</span><span class="log-m">${l.m}</span></div>`).join('');
|
||||
// Speicherplatz-Warnung
|
||||
const swb=$('space-warn-box'),swd=$('space-warn-detail');
|
||||
if(c.space_warning){
|
||||
swb.style.display='block';
|
||||
const needed=fmtBytes(c.space_needed||0), free=fmtBytes(c.space_free||0);
|
||||
const missing=fmtBytes(Math.max(0,(c.space_needed||0)-(c.space_free||0)));
|
||||
let detail=`Benötigt: <strong>${needed}</strong> · Verfügbar: <strong>${free}</strong> · Fehlend: <strong>${missing}</strong><br>Quelldateien werden nicht gelöscht.`;
|
||||
if(c.last_success_file) detail+=`<br>Zuletzt kopiert: <span style="font-family:monospace">${c.last_success_file}</span>`;
|
||||
swd.innerHTML=detail;
|
||||
}else{
|
||||
swb.style.display='none';
|
||||
}
|
||||
}catch(e){}
|
||||
// Upload status
|
||||
try{
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.70
|
||||
1.0.71
|
||||
|
||||
Reference in New Issue
Block a user