MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / api_upload_chunk

Function api_upload_chunk

Scripts/ButSystem.py:11787–11882  ·  view source on GitHub ↗

Upload a single vault chunk (sequential, resumable). Notes: - We require sequential chunk indices (0..total-1) because we append to a temp file. - Duplicate/retried chunks are safely ignored (won't corrupt the file). - Total size is capped at FILES_MAX_BYTES.

()

Source from the content-addressed store, hash-verified

11785
11786Internal helper function.
11787
11788This docstring was added automatically to improve maintainability.
11789
11790Args:
11791 username: Parameter.
11792 answers: Parameter.
11793
11794Returns:
11795 Varies.
11796"""
11797 conn = db_connect()
11798 row = conn.execute("SELECT a1_hash,a2_hash,a3_hash FROM user_security WHERE username=?", (username,)).fetchone()
11799 conn.close()
11800 if not row:
11801 return False
11802 for k, col in (("a1", "a1_hash"), ("a2", "a2_hash"), ("a3", "a3_hash")):
11803 if k in answers:
11804 h = row[col]
11805 if not h or not check_password_hash(h, _norm_answer(answers.get(k, ""))):
11806 return False
11807 return True
11808
11809@app.route("/settings", methods=["GET"])
11810@login_required
11811def settings_root():
11812 """Main settings entry point."""
11813 return redirect(url_for("settings_security"))
11814
11815@app.route("/settings/security", methods=["GET"])
11816@login_required
11817def settings_security():
11818 """Security settings page (2FA security questions, UI preferences)."""
11819 u = current_user()
11820
11821 # Defensive defaults to prevent 500s if DB isn't ready yet
11822 sec = {"enabled": 0, "q1": "", "q2": "", "q3": ""}
11823 prefs = dict(DEFAULT_PREFS)
11824
11825 try:
11826 if u:
11827 sec = get_user_security(u) or sec
11828 prefs = get_user_prefs(u) or prefs
11829 except Exception as e:
11830 try:
11831 app.logger.exception("settings_security failed: %s", e)
11832 except Exception:
11833 pass
11834
11835 return render_template(
11836 "settings_security.html",
11837 title="Settings",
11838 sec=sec,
11839 prefs=prefs,
11840 accent_choices=ACCENT_CHOICES,
11841 font_choices=FONT_CHOICES,
11842 ui_theme_choices=UI_THEME_CHOICES,
11843 )
11844

Callers

nothing calls this directly

Calls 5

_upload_meta_pathFunction · 0.70
current_userFunction · 0.70
_upload_tmp_pathFunction · 0.70
safe_relpathFunction · 0.70
abs_user_pathFunction · 0.70

Tested by

no test coverage detected