Skip to content

Commit 61ccd95

Browse files
committed
Fix missing mime type in happy path log
1 parent 3d5eb1e commit 61ccd95

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public final class MediaHelper {
6565
* or if the current thread is interrupted while converting a video file
6666
*/
6767
public static @Nullable File convert(File inputFile) throws Exception {
68-
return ScopedValue.where(MIME_TYPE, detectMimeType(inputFile)).call(() -> performConversion(inputFile, MIME_TYPE.get()));
68+
var mimeType = detectMimeType(inputFile);
69+
70+
return ScopedValue.where(MIME_TYPE, mimeType).call(() -> performConversion(inputFile, mimeType));
6971
}
7072

7173
/**
@@ -77,10 +79,7 @@ public final class MediaHelper {
7779
*/
7880
private static String detectMimeType(File file) throws MediaException {
7981
try {
80-
var mimeType = TIKA.detect(file);
81-
LOGGER.at(Level.DEBUG).log("MIME type successfully detected");
82-
83-
return mimeType;
82+
return TIKA.detect(file);
8483
} catch (IOException e) {
8584
LOGGER.at(Level.ERROR).addKeyValue("file_name", file.getName()).log("Unable to retrieve MIME type");
8685
throw new MediaException(e);
@@ -96,6 +95,8 @@ private static String detectMimeType(File file) throws MediaException {
9695
* @see MediaHelper#convert(File)
9796
*/
9897
private static @Nullable File performConversion(File inputFile, String mimeType) throws MediaException, InterruptedException {
98+
LOGGER.at(Level.DEBUG).log("MIME type successfully detected");
99+
99100
try {
100101
if (isSupportedVideo(mimeType)) {
101102
if (isVideoCompliant(inputFile)) {

0 commit comments

Comments
 (0)