mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 06:47:41 -05:00
Was hardcoded to 0L unconditionally. Generic-format bytes are summed live from the still-existing PublishPackageVersion records (packageVersions), the same lazily-computed-not-cached pattern repositoryCount already uses. Scoped per still-live repository rather than one scan over the whole domain, matching every other read path's own per-repository prefix. Maven, npm, and pypi have no such record to sum: their publishes go straight to their own sidecar (Reposilite/Verdaccio/pypiserver) and never create one. Each proxy now reports its own successfully-written byte count directly through a new recordContainerBackedAssetBytes, keyed exactly like packageOriginConfigs (region/domain/repository/format/namespace/package, no version), only once it has already decided, in its own terms, that a real write just happened: - Maven: ReposiliteSidecarClient.deployArtifact now returns a DeployOutcome (status plus whether it actually wrote new content), so the idempotent-match short-circuit and a genuine redeployment:false conflict both correctly add nothing. CodeArtifactMavenController parses the GAV path into namespace/package name, including a group/artifact-level maven-metadata.xml upload, which it attributes correctly once the metadata filename itself (not the segment count) tells it apart from a real versioned asset. - npm: NpmPublishEnvelopeScanner's attachment digest loop now also counts the real decoded byte count alongside its SHA-512, so a multi-attachment publish is sized by its actual tarball bytes, not the base64-and-JSON envelope. Recorded only after Verdaccio's own response confirms a 200/201, off the event loop (vertx.executeBlocking, on principle, even though the call itself is cheap); the confirmed-republish short-circuit and a native Verdaccio rejection both add nothing. A native npm unpublish (Verdaccio's unpublish:$all, bypassing this service entirely) is detected separately and cleaned up the same way DeletePackage would have. - pypi: recorded after a real forwarded upload succeeds, under pypiserver's own PEP 503 normalized name so an upload and a later delete spelled differently still address the same count; the byte-identical idempotent short-circuit and the different-content 409 both add nothing. DeleteRepository and DeletePackage both clean up every format's own records (packageVersions and its asset content included) by the same name-based prefix/key, so a repository or package recreated under the same name never inherits a predecessor's bytes. A per-package deletion fence, bumped only by an actual delete (DeletePackage, or a native npm unpublish), replaces a sidecar existence re-check for the race between an in-flight publish's own accounting and a concurrent delete: comparing a snapshot taken before the real write against the fence's current value catches "deleted" and "deleted and republished under the same name" alike, with no network round trip needed to do it, so nothing here holds the service-wide lock across a sidecar call. containerBackedAssetBytes itself is kept in memory only, like the fence, not through StorageFactory: the sidecar content it counts does not survive a Floci restart either, so neither does the count. Verified against real Reposilite, Verdaccio, and pypiserver containers (not just mocks): each Docker-gated integration suite asserts assetSizeBytes increases by exactly the real published/uploaded byte count, stays unchanged across an idempotent retry, and drops back down after a real delete, native unpublish included. Known limitations documented: a maven-metadata.xml for a versioned snapshot is attributed to its version string rather than its real artifact name (still counted correctly in the domain total, just under a misnamed bucket nothing else looks up by name); unpublishing a single version of a multi-version npm package is not detected (this accounting is per-package, not per-version, so there is no narrower count to subtract from regardless). Addresses hectorvent's review on the PR: rebased to pick up #5102's Digests.sha256Hex (the tests were merging clean but failing to compile against current main), stopped containerBackedAssetBytes from surviving a restart the content it counts does not, and closed the native-npm-unpublish gap in the fence's own soundness argument.