Store a DM voice message using an existing DB connection/transaction. This prevents a race where other clients can see the message before the attachment is saved/linked, which previously caused "blank" voice/file rows until a refresh.
(conn, dm_id: int, file_storage)
| 12626 | def delete(): |
| 12627 | rel = request.form.get("p", "") or ""; parent = "" |
| 12628 | try: |
| 12629 | rel = safe_relpath(rel); parent = "/".join(rel.split("/")[:-1]) if rel else "" |
| 12630 | if not rel: raise ValueError("root") |
| 12631 | target = abs_user_path(current_user(), rel) |
| 12632 | if os.path.isdir(target): shutil.rmtree(target) |
| 12633 | else: os.remove(target) |
| 12634 | _delete_file_metadata(current_user(), rel); _log_file_activity(current_user(), "entry_deleted", rel); flash("Entry deleted.") |
| 12635 | except Exception: flash("Delete failed.") |
| 12636 | return redirect(url_for("files", p=parent)) |
| 12637 | |
| 12638 | |
| 12639 | def _zip_paths(owner: str, relpaths: List[str], archive_label: str) -> str: |
| 12640 | os.makedirs(TMP_UPLOAD_DIR, exist_ok=True) |
| 12641 | estimated = 0 |
| 12642 | for rel in relpaths: |
| 12643 | target = abs_user_path(owner, safe_relpath(rel)) |
| 12644 | if os.path.isdir(target): |
| 12645 | estimated += _folder_size(target) |
| 12646 | elif os.path.isfile(target): |
| 12647 | estimated += os.path.getsize(target) |
| 12648 | usage = shutil.disk_usage(TMP_UPLOAD_DIR) |
| 12649 | # ZIP creation needs temporary local space. Use a conservative source-size estimate. |
| 12650 | if estimated > usage.free or (usage.total and ((usage.used + estimated) / usage.total) >= 0.95): |
| 12651 | raise OSError("Not enough temporary storage to create ZIP") |
| 12652 | fd, zip_path = tempfile.mkstemp(prefix="vault-download-", suffix=".zip", dir=TMP_UPLOAD_DIR); os.close(fd) |
no test coverage detected