feat: Verbindungstest für Remote-Ziele hinzugefügt und Versionsnummer auf 1.0.33 erhöht
This commit is contained in:
47
app.py
47
app.py
@@ -908,8 +908,28 @@ def delete_remote(tid):
|
||||
|
||||
|
||||
def test_remote(tid):
|
||||
r = _rclone('lsd', f'{_remote_name(tid)}:', timeout=20)
|
||||
return r.returncode == 0, r.stderr.strip()
|
||||
remote = _remote_name(tid)
|
||||
# 1. Verbindung prüfen (Verzeichnis auflisten)
|
||||
r = _rclone('lsd', f'{remote}:', timeout=20)
|
||||
if r.returncode != 0:
|
||||
err = r.stderr.strip().splitlines()[-1] if r.stderr.strip() else 'Verbindung fehlgeschlagen'
|
||||
return False, f'Verbindung: {err}'
|
||||
# 2. Schreibzugriff prüfen (Test-Datei schreiben und löschen)
|
||||
test_file = f'{remote}:picopy_writetest_{int(time.time())}.tmp'
|
||||
import tempfile, os as _os
|
||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.tmp', delete=False) as tf:
|
||||
tf.write('PiCopy write test')
|
||||
tmp_path = tf.name
|
||||
try:
|
||||
rw = _rclone('copyto', tmp_path, test_file, timeout=20)
|
||||
if rw.returncode != 0:
|
||||
err = rw.stderr.strip().splitlines()[-1] if rw.stderr.strip() else 'Schreiben fehlgeschlagen'
|
||||
return False, f'Kein Schreibzugriff: {err}'
|
||||
_rclone('deletefile', test_file, timeout=10)
|
||||
finally:
|
||||
try: _os.unlink(tmp_path)
|
||||
except Exception: pass
|
||||
return True, ''
|
||||
|
||||
|
||||
def run_uploads(local_dir: Path, cfg: dict):
|
||||
@@ -2234,10 +2254,11 @@ function renderUTs(){
|
||||
<div class="ut-meta">SMB/NAS | ${t.dest_path}</div>
|
||||
</div>
|
||||
<div class="ut-acts">
|
||||
<button class="btn sm ghost" onclick="utTest('${t.id}','${t.name}')">Test</button>
|
||||
<button class="btn sm ghost" id="ut-test-${t.id}" onclick="utTest('${t.id}')">🔍 Test</button>
|
||||
<button class="btn sm ${t.enabled?'grn':'ghost'}" onclick="utToggle('${t.id}')">${t.enabled?'Aktiv':'Inaktiv'}</button>
|
||||
<button class="btn sm danger" onclick="utDel('${t.id}','${t.name}')">✕</button>
|
||||
</div>
|
||||
<div id="ut-test-result-${t.id}" style="display:none;font-size:.76rem;margin-top:.35rem;padding:.3rem .5rem;border-radius:.35rem"></div>
|
||||
</div>`).join('');
|
||||
}
|
||||
function utToggleForm(){
|
||||
@@ -2274,13 +2295,25 @@ async function utSave(){
|
||||
flash('ut-form-flash','ok','Speichere...');
|
||||
const r=await api('/upload/targets','POST',body);
|
||||
if(r.error){flash('ut-form-flash','err',r.error);return;}
|
||||
flash('ut-form-flash','ok','Teste Verbindung...');
|
||||
const t=await api('/upload/targets/'+r.id+'/test','POST');
|
||||
if(t.ok){flash('ut-form-flash','ok','✓ Verbindung OK!');utToggleForm();await loadUTs();}
|
||||
else flash('ut-form-flash','err','Test fehlgeschlagen: '+t.error);
|
||||
if(t.ok){flash('ut-form-flash','ok','✓ Verbindung OK - Lesen & Schreiben erfolgreich');utToggleForm();await loadUTs();}
|
||||
else flash('ut-form-flash','err','✗ ' + (t.error||'Test fehlgeschlagen'));
|
||||
}
|
||||
async function utTest(id,name){
|
||||
async function utTest(id){
|
||||
const btn=$('ut-test-'+id), res=$('ut-test-result-'+id);
|
||||
btn.disabled=true; btn.textContent='Teste...';
|
||||
res.style.display='none';
|
||||
const r=await api('/upload/targets/'+id+'/test','POST');
|
||||
alert(r.ok?'✓ Verbindung zu "'+name+'" erfolgreich!':'✗ Fehler: '+r.error);
|
||||
btn.disabled=false; btn.innerHTML='🔍 Test';
|
||||
res.style.display='block';
|
||||
if(r.ok){
|
||||
res.style.background='rgba(52,211,153,.12)'; res.style.color='var(--grn)';
|
||||
res.textContent='✓ Verbindung OK - Lesen & Schreiben erfolgreich';
|
||||
} else {
|
||||
res.style.background='rgba(248,113,113,.1)'; res.style.color='var(--red)';
|
||||
res.textContent='✗ ' + (r.error||'Test fehlgeschlagen');
|
||||
}
|
||||
}
|
||||
async function utToggle(id){await api('/upload/targets/'+id+'/toggle','POST');await loadUTs();}
|
||||
async function utDel(id,name){
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.32
|
||||
1.0.33
|
||||
Reference in New Issue
Block a user