Privacy Policy DSGVO with sheets for categories, export-, check- and first erase-functions
This commit is contained in:
+22
-4
@@ -1280,14 +1280,14 @@ def _job_log(job_id: str, level: str, message: str) -> None:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def _run_sync_job(job_id: str) -> None:
|
||||
def _run_sync_job(job_id: str, dry_run: bool = False) -> None:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
result = synchronize(db, lambda level, message: _job_log(job_id, level, message))
|
||||
result = synchronize(db, lambda level, message: _job_log(job_id, level, message), dry_run=dry_run)
|
||||
with SYNC_JOBS_LOCK:
|
||||
job = SYNC_JOBS[job_id]
|
||||
job["status"] = result.run.status
|
||||
job["run_id"] = result.run.id
|
||||
job["run_id"] = result.run.id if not dry_run else None
|
||||
job["finished"] = True
|
||||
except Exception as exc:
|
||||
_job_log(job_id, "error", f"Unerwarteter Fehler: {exc}")
|
||||
@@ -8064,6 +8064,22 @@ def meshcentral_sync_start(request: Request):
|
||||
return {"job_id": job_id}
|
||||
|
||||
|
||||
@app.post("/sync/meshcentral/dry-run")
|
||||
def meshcentral_sync_dry_run(request: Request):
|
||||
_require_admin(request)
|
||||
with SYNC_JOBS_LOCK:
|
||||
if any(not job.get("finished") for job in SYNC_JOBS.values()):
|
||||
return JSONResponse({"error": "Es läuft bereits eine Synchronisierung oder ein Dry-Run."}, status_code=409)
|
||||
job_id = uuid.uuid4().hex
|
||||
SYNC_JOBS[job_id] = {
|
||||
"status": "dry-run", "finished": False, "run_id": None,
|
||||
"logs": [], "created_at": datetime.now().isoformat(), "dry_run": True,
|
||||
}
|
||||
_job_log(job_id, "info", "Dry-Run-Auftrag angelegt. Es werden keine Änderungen gespeichert.")
|
||||
threading.Thread(target=_run_sync_job, args=(job_id, True), daemon=True).start()
|
||||
return {"job_id": job_id}
|
||||
|
||||
|
||||
@app.get("/sync/meshcentral/jobs/{job_id}")
|
||||
def meshcentral_sync_job(job_id: str, offset: int = 0):
|
||||
with SYNC_JOBS_LOCK:
|
||||
@@ -8180,8 +8196,10 @@ async def meshcentral_settings_save(request: Request, db: Session = Depends(get_
|
||||
'create_missing_assets': form.get('create_missing_assets') == 'on',
|
||||
'mark_missing_devices': form.get('mark_missing_devices') == 'on',
|
||||
'store_source_json': form.get('store_source_json') == 'on',
|
||||
'serial_match_manufacturer': form.get('serial_match_manufacturer') == 'on',
|
||||
})
|
||||
mesh['match_order'] = form.getlist('match_order') or ['node_id', 'serial_number']
|
||||
submitted_match_order = [value for value in form.getlist('match_order') if value in {'node_id', 'serial_number'}]
|
||||
mesh['match_order'] = submitted_match_order or ['node_id', 'serial_number']
|
||||
# Do not retain plaintext passwords from older versions.
|
||||
mesh.pop('password', None)
|
||||
mesh.pop('field_mappings', None)
|
||||
|
||||
Reference in New Issue
Block a user