Refacor gitinfo service

This commit is contained in:
2026-01-06 09:55:35 +01:00
parent e2d3b0975c
commit 580119d97b
2 changed files with 12 additions and 9 deletions

View File

@@ -44,10 +44,9 @@ public class ChannelDirectoryService {
private final MediaDetectionService mediaDetectionService;
private final MediaOptimizationService mediaOptimizationService;
private final SettingsService settingsService;
private final long uploadLimitBytes;
@Autowired
private long uploadLimitBytes;
public ChannelDirectoryService(
ChannelRepository channelRepository,
AssetRepository assetRepository,
@@ -55,7 +54,8 @@ public class ChannelDirectoryService {
AssetStorageService assetStorageService,
MediaDetectionService mediaDetectionService,
MediaOptimizationService mediaOptimizationService,
SettingsService settingsService
SettingsService settingsService,
long uploadLimitBytes
) {
this.channelRepository = channelRepository;
this.assetRepository = assetRepository;
@@ -64,6 +64,7 @@ public class ChannelDirectoryService {
this.mediaDetectionService = mediaDetectionService;
this.mediaOptimizationService = mediaOptimizationService;
this.settingsService = settingsService;
this.uploadLimitBytes = uploadLimitBytes;
}
public Channel getOrCreateChannel(String broadcaster) {
@@ -154,8 +155,10 @@ public class ChannelDirectoryService {
.orElse("asset_" + System.currentTimeMillis());
boolean isAudio = optimized.mediaType().startsWith("audio/");
double width = optimized.width() > 0 ? optimized.width() : isAudio ? 400 : 640;
double height = optimized.height() > 0 ? optimized.height() : isAudio ? 80 : 360;
double defaultWidth = isAudio ? 400 : 640;
double defaultHeight = isAudio ? 80 : 360;
double width = optimized.width() > 0 ? optimized.width() : defaultWidth;
double height = optimized.height() > 0 ? optimized.height() : defaultHeight;
Asset asset = new Asset(channel.getBroadcaster(), safeName, "", width, height);
asset.setOriginalMediaType(mediaType);

View File

@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
@Component
public class GitInfoService {
private static final String FALLBACK_GIT_SHA = "unknown";
private static final Logger LOG = LoggerFactory.getLogger(GitInfoService.class);
private static final String COMMIT_URL_PREFIX = "https://github.com/Kruhlmann/imgfloat-j/commit/";
@@ -46,7 +46,7 @@ public class GitInfoService {
}
public String getCommitUrl() {
if (commitSha == null || commitSha.isBlank() || "unknown".equalsIgnoreCase(commitSha)) {
if (commitSha == null || commitSha.isBlank() || FALLBACK_GIT_SHA.equalsIgnoreCase(commitSha)) {
return null;
}
return COMMIT_URL_PREFIX + commitSha;
@@ -118,9 +118,9 @@ public class GitInfoService {
private String defaultValue(String value) {
if (value == null || value.isBlank()) {
return "unknown";
return FALLBACK_GIT_SHA;
}
return "unknown".equalsIgnoreCase(value) ? "unknown" : value;
return value;
}
private record CommitInfo(String fullSha, String shortSha) {}