commit 4d3f79da10cd62c8b2cbe421bddb3502fc9099d4
parent 4e460ed2be58f8d3d70fa281c1a804013e037659
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Wed, 8 May 2024 14:28:20 +0200
fix(download_processor): better duplicate check
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/download/DownloadProcessor.kt b/app/src/main/kotlin/me/rhunk/snapenhance/download/DownloadProcessor.kt
@@ -131,6 +131,11 @@ class DownloadProcessor (
// checks if the file already exists and if it does, compares its contents with the input file, if contents differ, deletes existing file.
outputFileFolder.findFile(fileName)?.let { existingFile ->
pendingTask.updateProgress("Comparing existing media")
+ if (existingFile.length() != inputFile.length()) {
+ existingFile.delete()
+ return@let
+ }
+
remoteSideContext.androidContext.contentResolver.openInputStream(existingFile.uri)?.use { existingInputStream ->
val buffer1 = ByteArray(1024 * 1024)
val buffer2 = ByteArray(1024 * 1024)