From 715b86b09b3c0d55cd2663e82fb357896ee8519a Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Wed, 15 Feb 2017 08:27:11 +0100 Subject: [PATCH] Tried skipping files in case of a timeout instead of just retrying. Then noticed that the timeout couldn't actually be thrown. Added logging for that case to investigate. --- .../telegram_backup/CommandLineDownloadProgress.java | 2 ++ .../fabianonline/telegram_backup/DownloadManager.java | 10 ++++++++-- .../telegram_backup/DownloadProgressInterface.java | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/fabianonline/telegram_backup/CommandLineDownloadProgress.java b/src/main/java/de/fabianonline/telegram_backup/CommandLineDownloadProgress.java index 12c8244..d56a4c8 100644 --- a/src/main/java/de/fabianonline/telegram_backup/CommandLineDownloadProgress.java +++ b/src/main/java/de/fabianonline/telegram_backup/CommandLineDownloadProgress.java @@ -36,6 +36,7 @@ class CommandLineDownloadProgress implements DownloadProgressInterface { System.out.println("'S' - Sticker 'A' - Audio 'G' - Geolocation"); System.out.println("'.' - Previously downloaded file 'e' - Empty file"); System.out.println("' ' - Ignored media type (weblinks or contacts, for example)"); + System.out.println("'x' - File skipped because of timeout errors"); System.out.println("" + count + " Files to check / download"); } @@ -47,6 +48,7 @@ class CommandLineDownloadProgress implements DownloadProgressInterface { public void onMediaAlreadyPresent(AbstractMediaFileManager fm) { show("."); } + public void onMediaSkipped() { show("x"); } public void onMediaDownloadFinished() { showNewLine(); System.out.println("Done."); } diff --git a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java index 3c99f9e..1681088 100644 --- a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java +++ b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java @@ -239,6 +239,7 @@ public class DownloadManager { System.out.println(""); System.out.println("Telegram took too long to respond to our request."); System.out.println("I'm going to wait a minute and then try again."); + logger.warn("TimeoutException caught", e); try { TimeUnit.MINUTES.sleep(1); } catch(InterruptedException e2) {} System.out.println(""); } @@ -271,8 +272,13 @@ public class DownloadManager { } else if (m.isDownloaded()) { prog.onMediaAlreadyPresent(m); } else { - m.download(); - prog.onMediaDownloaded(m); + /*try {*/ + m.download(); + prog.onMediaDownloaded(m); + /*} catch (TimeoutException e) { + // do nothing - skip this file + prog.onMediaSkipped(); + }*/ } } prog.onMediaDownloadFinished(); diff --git a/src/main/java/de/fabianonline/telegram_backup/DownloadProgressInterface.java b/src/main/java/de/fabianonline/telegram_backup/DownloadProgressInterface.java index b555005..6924e59 100644 --- a/src/main/java/de/fabianonline/telegram_backup/DownloadProgressInterface.java +++ b/src/main/java/de/fabianonline/telegram_backup/DownloadProgressInterface.java @@ -26,6 +26,7 @@ public interface DownloadProgressInterface { public void onMediaDownloadStart(int count); public void onMediaDownloaded(AbstractMediaFileManager a); public void onMediaDownloadedEmpty(); + public void onMediaSkipped(); public void onMediaAlreadyPresent(AbstractMediaFileManager a); public void onMediaDownloadFinished(); }