1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-12-25 06:15:35 +00:00

Merge branch 'master' of https://github.com/leijurv/telegram_backup into pull-leijurv-master

This commit is contained in:
Fabian Schlenz 2018-03-03 22:06:36 +01:00
commit d4a6141862

View File

@ -316,7 +316,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
try {
_downloadMedia()
} catch (e: RpcErrorException) {
if (e.getTag().startsWith("420: FLOOD_WAIT_")) {
if (e.getCode() == 420) { // FLOOD_WAIT
completed = false
Utils.obeyFloodWaitException(e)
} else {
@ -432,9 +432,10 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
try {
response = download_client!!.executeRpcQuery(req, dcID) as TLFile
} catch (e: RpcErrorException) {
if (e.getTag().startsWith("420: FLOOD_WAIT_")) {
if (e.getCode() == 420) { // FLOOD_WAIT
try_again = true
Utils.obeyFloodWaitException(e)
continue // response is null since we didn't actually receive any data. Skip the rest of this iteration and try again.
} else if (e.getCode() == 400) {
//Somehow this file is broken. No idea why. Let's skip it for now
return false
@ -453,7 +454,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
} catch (e: InterruptedException) {
}
} while (offset < size && (response!!.getBytes().getData().size > 0 || try_again))
} while (offset < size && (try_again || response!!.getBytes().getData().size > 0))
fos.close()
if (offset < size) {
System.out.println("Requested file $target with $size bytes, but got only $offset bytes.")