diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/util/CacheCleaner.java b/ultrasonic/src/main/java/org/moire/ultrasonic/util/CacheCleaner.java index f9d71d20..890788f8 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/util/CacheCleaner.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/util/CacheCleaner.java @@ -229,7 +229,7 @@ public class CacheCleaner for (DownloadFile downloadFile : downloader.getValue().getDownloads()) { filesToNotDelete.add(downloadFile.getPartialFile()); - filesToNotDelete.add(downloadFile.getCompleteFile()); + filesToNotDelete.add(downloadFile.getCompleteOrSaveFile()); } filesToNotDelete.add(FileUtil.getMusicDirectory(context)); diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/util/StreamProxy.java b/ultrasonic/src/main/java/org/moire/ultrasonic/util/StreamProxy.java index 0e9870c6..8dfb1cd5 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/util/StreamProxy.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/util/StreamProxy.java @@ -194,7 +194,7 @@ public class StreamProxy implements Runnable while (isRunning && !client.isClosed()) { // See if there's more to send - File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); + File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteOrSaveFile() : downloadFile.getPartialFile(); int cbSentThisBatch = 0; if (file.exists()) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadFile.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadFile.kt index d1039fd3..3754d645 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadFile.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/service/DownloadFile.kt @@ -100,19 +100,16 @@ class DownloadFile( } } - fun getCompleteFile(): File { - if (saveFile.exists()) { - return saveFile - } - - return if (completeFile.exists()) { + val completeOrSaveFile: File + get() = if (saveFile.exists()) { + saveFile + } else { completeFile - } else saveFile - } + } val completeOrPartialFile: File get() = if (isCompleteFileAvailable) { - getCompleteFile() + completeOrSaveFile } else { partialFile }