From f9816ec335adcc18dcc74e714659c0f54831bcda Mon Sep 17 00:00:00 2001 From: junhuicoding Date: Sat, 3 Apr 2021 04:05:00 +0800 Subject: [PATCH] Fix checkDownloaded to check for both with and without username --- .../java/awais/instagrabber/utils/DownloadUtils.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java index 52b6a41d..b125b320 100644 --- a/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/DownloadUtils.java @@ -212,14 +212,13 @@ public final class DownloadUtils { username = user.getUsername(); } final File downloadDir = getDownloadDir(null, "@" + username, true); - final String usernamePrepend = Utils.settingsHelper.getBoolean(Constants.DOWNLOAD_PREPEND_USER_NAME) - && user != null ? username : ""; switch (media.getMediaType()) { case MEDIA_TYPE_IMAGE: case MEDIA_TYPE_VIDEO: { final String url = ResponseBodyUtils.getImageUrl(media); - final File file = getDownloadSaveFile(downloadDir, media.getCode(), url, usernamePrepend); - checkList.add(file.exists()); + final File file = getDownloadSaveFile(downloadDir, media.getCode(), url, ""); + final File usernamePrependedFile = getDownloadSaveFile(downloadDir, media.getCode(), url, username); + checkList.add(file.exists() || usernamePrependedFile.exists()); break; } case MEDIA_TYPE_SLIDER: @@ -228,8 +227,9 @@ public final class DownloadUtils { final Media child = sliderItems.get(i); if (child == null) continue; final String url = ResponseBodyUtils.getImageUrl(child); - final File file = getDownloadChildSaveFile(downloadDir, media.getCode(), i + 1, url, usernamePrepend); - checkList.add(file.exists()); + final File file = getDownloadChildSaveFile(downloadDir, media.getCode(), i + 1, url, ""); + final File usernamePrependedFile = getDownloadChildSaveFile(downloadDir, media.getCode(), i + 1, url, username); + checkList.add(file.exists() || usernamePrependedFile.exists()); } break; default: