refactor(web): authoritative Content-Length, typed Optional<AppVersion> in controller
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user