refactor(web): authoritative Content-Length, typed Optional<AppVersion> in controller

This commit is contained in:
hsiegeln
2026-04-27 15:47:37 +02:00
parent 433155ae0c
commit 940bf18aba
7 changed files with 43 additions and 13 deletions

View File

@@ -13,6 +13,7 @@ import java.security.MessageDigest;
import java.util.HexFormat;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.regex.Pattern;
@@ -57,6 +58,13 @@ public class AppService {
.orElseThrow(() -> new IllegalArgumentException("AppVersion not found: " + versionId));
}
/** Typed Optional accessor for callers that distinguish missing-rows from
* other failures without relying on the message-based exception convention
* of {@link #getVersion(UUID)}. */
public Optional<AppVersion> findVersion(UUID versionId) {
return versionRepo.findById(versionId);
}
/** Coordinate corresponding to an AppVersion. Used by callers that need to
* pass the artifact identity to {@link ArtifactStore} (download, delete, exists). */
public ArtifactCoordinates coordinatesFor(AppVersion version) {

View File

@@ -22,6 +22,11 @@ public interface ArtifactStore {
/** Open the artifact for reading. Caller closes. */
InputStream get(ArtifactCoordinates coords) throws IOException;
/** Size of the stored artifact in bytes. Authoritative — read from the backend
* at serve time so a stale {@code AppVersion.jarSizeBytes} cannot silently
* truncate downloads. */
long size(ArtifactCoordinates coords) throws IOException;
/** True if an artifact is currently stored under {@code coords}. */
boolean exists(ArtifactCoordinates coords);