diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-09 18:23:52 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-09 18:23:56 +0200 |
| commit | c85c7f48e8f29923038d4c90cc1a6f9b8bcd7673 (patch) | |
| tree | 10a5a62416bafd58c891e1fff290036bb75c7318 /packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py | |
| parent | fbc2c5d86aed931be38c5fccfff75190eb4d16d1 (diff) | |
| download | meshbay-c85c7f48e8f29923038d4c90cc1a6f9b8bcd7673.tar.gz | |
feat(node): refuse an upload on a full disk with a stated reason
Nothing on the upload path knew about ENOSPC: a write that found no room
raised out of the handler, the catch-all answered "Request failed", and the
.part stayed behind holding the space that had run out. The node now refuses
with `disk_full` at chunk 0 when the announced size would leave less than
1 GiB free, and at any write that fails with ENOSPC/EDQUOT, dropping the
partial. The client carries the code on the error and the transfers panel
says "The node's disk is full" in every catalogue.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py index 2e484de..e298942 100644 --- a/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py +++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc/disk.py @@ -1,5 +1,6 @@ """Blocking disk work the session hands to `off_disk`.""" +import shutil from pathlib import Path from meshbay_common.protocol import file_chunk_wire @@ -76,6 +77,12 @@ def _read_and_encrypt( return file_chunk_wire(gek, plaintext, chunk_index, file_hash, file_id) +def _free_bytes(directory: Path) -> int: + """Space left on the filesystem holding `directory`. Blocking; called + through `off_disk`, since a `statvfs` wakes a sleeping disk like any stat.""" + return shutil.disk_usage(directory).free + + def _append_chunk(tmp_path: Path, chunk_bytes: bytes, first: bool) -> None: """Add one chunk to a partial upload. Blocking; called through `off_disk`.""" with open(tmp_path, "wb" if first else "ab") as f: |