From 7a30f1a1129bfacad068356a27b335aa1e7a34c0 Mon Sep 17 00:00:00 2001 From: jarvis2f <137974272+jarvis2f@users.noreply.github.com> Date: Sat, 8 Feb 2025 11:36:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20feat:=20Add=20logic=20to=20handl?= =?UTF-8?q?e=20file=20redownload=20when=20it=20cannot=20be=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/src/main/java/telegram/files/TelegramVerticle.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/src/main/java/telegram/files/TelegramVerticle.java b/api/src/main/java/telegram/files/TelegramVerticle.java index 1659850..3e8fdc9 100644 --- a/api/src/main/java/telegram/files/TelegramVerticle.java +++ b/api/src/main/java/telegram/files/TelegramVerticle.java @@ -439,6 +439,13 @@ public class TelegramVerticle extends AbstractVerticle { if (!isPaused && file.local.isDownloadingActive) { return Future.failedFuture("File is downloading"); } + if (!isPaused && !file.local.canBeDeleted) { + // Maybe the file is not exist, so we need to redownload it + return DataVerticle.fileRepository.getByUniqueId(file.remote.uniqueId) + .compose(fileRecord -> + client.execute(new TdApi.AddFileToDownloads(fileId, fileRecord.chatId(), fileRecord.messageId(), 32))) + .mapEmpty(); + } return client.execute(new TdApi.ToggleDownloadIsPaused(fileId, isPaused)); })