Skip to content
This repository was archived by the owner on Apr 18, 2023. It is now read-only.

Commit 005ddc6

Browse files
committed
Fix unreachable code in CoverLoader from extra return statement.
1 parent 5106bca commit 005ddc6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

nup/src/main/java/CoverLoader.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ open class CoverLoader(
5353

5454
var file = lookForLocalCover(url)
5555
if (file != null) {
56-
Log.d(TAG, "Found local file ${file.name}")
56+
Log.d(TAG, "Using local file ${file.name}")
5757
} else {
58-
file = downloadCover(url)
59-
if (file != null) Log.d(TAG, "Fetched remote file ${file.name}")
58+
file = downloadCover(url) ?: return null
59+
Log.d(TAG, "Fetched remote file ${file.name}")
6060
}
61-
if (file == null || !file.exists()) return null
6261

63-
// TODO: The compiler gives an incorrect "Unreachable code" warning about the next line.
64-
return lastLock.withLock {
62+
if (!file.exists()) {
63+
Log.e(TAG, "${file.name} disappeared")
64+
return null
65+
}
66+
67+
lastLock.withLock {
6568
if (lastFile != null && lastFile == file) return lastBitmap
6669
lastFile = file
6770
lastBitmap = decodeFile(file.path)

0 commit comments

Comments
 (0)