mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
PublishPackageVersion and the Maven, pypi, and NuGet wire-protocol endpoints all received the request body as a single byte[] before any size check ran, so the real, documented 5 GB asset quota never actually applied: an array is capped at ~2.147 GB (Integer.MAX_VALUE), so a legitimately-sized multi-GB asset either failed with an OOM or never got far enough to hit the quota check at all. Reworks the write path for all four formats to stream through a staged file instead of a resident array: - AssetDigestingInputStream computes MD5/SHA-1/SHA-256/SHA-512 and enforces the 5 GB cap in one pass while the body is read, rather than after it's fully buffered. - CodeArtifactService.stageAssetBody/deleteStagedAssetBody give every upload path a single, consistent staged-file lifecycle; existing byte[]-based entry points (CopyPackageVersions, small in-process metadata writes) are left as additive overloads, not replaced, so ~120 existing direct-call test fixtures keep working unchanged. - MultipartFormParser.extractFilePart streams a pypi/NuGet multipart body from disk in fixed-size chunks with a carried-over overlap window, so a boundary marker that straddles two reads is still found correctly, without ever holding the whole envelope (or the file part inside it) in one array. Text fields are bounded both individually and in aggregate, so a real long pypi description doesn't get rejected but many small fields together still can't accumulate the whole envelope on the heap. - Every sidecar write (Reposilite, pypiserver, BaGetter) now has a Path/InputStream-based overload alongside its existing byte[] one, using HttpRequest.BodyPublishers.ofFile/concat instead of a resident buffer. Verdaccio's own write streams the base64-encoded tarball through a piped JDK Base64 encoder instead of building one large encoded string, and a writer-side read failure now fails the publish outright instead of risking a truncated tarball published under hashes computed from the whole file. - Every large-transfer HTTP call site's timeout now scales with the content length (SidecarUriUtils.transferTimeout) instead of a flat 30 seconds, which a multi-GB transfer can legitimately exceed. Manually verified against a packaged jar running under a 1 GB heap cap: a 3 GiB Maven deploy, a 3 GiB pypi twine-shaped upload, and a 3.2 GB NuGet push each completed with no OOM and round-tripped byte-identical. Documents two related, pre-existing ceilings that this change does not and cannot remove on its own: the emulator's own global HTTP body-size cap (FLOCI_PROTOCOLS_MAX_REQUEST_SIZE, 2048 MB by default) still caps any single request below the real 5 GB quota until raised, and the generic format's in-memory storage mode still holds an asset as one byte[].