From 0db0542d798cfc3a43505189665a6f98be2fd830 Mon Sep 17 00:00:00 2001 From: Oscar Date: Sat, 22 Apr 2017 13:24:29 +0200 Subject: [PATCH] Fixes #46: No more errors while downloading files (with quite large filesize) from Telegram. --- README.md | 4 +--- .../java/de/fabianonline/telegram_backup/DownloadManager.java | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fd622fc..cc8385d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Telegram_Backup -Copyright 2016 Fabian Schlenz +Copyright 2017 Fabian Schlenz Licensed under GPLv3 ## Description @@ -59,8 +59,6 @@ amazon. The library I'm using to access Telegram has some small bugs. One of those is the display of meaningless (because they are being acted accordingly upon) error messages. Those include: -* `Exception in thread "pool-x-thread-y" java.lang.Error: -java.nio.channels.ClosedChannelException` * Something containing `AUTH_ERROR` You can just ignore these messages. diff --git a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java index 5959f9a..1f5ea14 100644 --- a/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java +++ b/src/main/java/de/fabianonline/telegram_backup/DownloadManager.java @@ -323,7 +323,7 @@ public class DownloadManager { boolean try_again; do { try_again = false; - int block_size = size; + int block_size = 1024; logger.trace("offset: {} block_size: {} size: {}", offset, block_size, size); TLRequestUploadGetFile req = new TLRequestUploadGetFile(loc, offset, block_size); try { @@ -350,7 +350,6 @@ public class DownloadManager { fos.write(response.getBytes().getData()); fos.flush(); - try { TimeUnit.MILLISECONDS.sleep(Config.DELAY_AFTER_GET_FILE); } catch(InterruptedException e) {} } while(offset < size && (response.getBytes().getData().length>0 || try_again)); fos.close(); if (offset < size) { @@ -377,6 +376,7 @@ public class DownloadManager { throw last_exception; } last_download_succeeded = true; + try { TimeUnit.MILLISECONDS.sleep(Config.DELAY_AFTER_GET_FILE); } catch(InterruptedException e) {} return true; } catch (java.io.IOException ex) { if (fos!=null) fos.close();