mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
commit
14324dfa4c
@ -316,7 +316,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
|
|||||||
try {
|
try {
|
||||||
_downloadMedia()
|
_downloadMedia()
|
||||||
} catch (e: RpcErrorException) {
|
} catch (e: RpcErrorException) {
|
||||||
if (e.getTag().startsWith("420: FLOOD_WAIT_")) {
|
if (e.getCode() == 420) { // FLOOD_WAIT
|
||||||
completed = false
|
completed = false
|
||||||
Utils.obeyFloodWaitException(e)
|
Utils.obeyFloodWaitException(e)
|
||||||
} else {
|
} else {
|
||||||
@ -432,9 +432,10 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
|
|||||||
try {
|
try {
|
||||||
response = download_client!!.executeRpcQuery(req, dcID) as TLFile
|
response = download_client!!.executeRpcQuery(req, dcID) as TLFile
|
||||||
} catch (e: RpcErrorException) {
|
} catch (e: RpcErrorException) {
|
||||||
if (e.getTag().startsWith("420: FLOOD_WAIT_")) {
|
if (e.getCode() == 420) { // FLOOD_WAIT
|
||||||
try_again = true
|
try_again = true
|
||||||
Utils.obeyFloodWaitException(e)
|
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) {
|
} else if (e.getCode() == 400) {
|
||||||
//Somehow this file is broken. No idea why. Let's skip it for now
|
//Somehow this file is broken. No idea why. Let's skip it for now
|
||||||
return false
|
return false
|
||||||
@ -443,7 +444,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += response!!.getBytes().getData().size
|
offset += response.getBytes().getData().size
|
||||||
logger.trace("response: {} total size: {}", response.getBytes().getData().size, offset)
|
logger.trace("response: {} total size: {}", response.getBytes().getData().size, offset)
|
||||||
|
|
||||||
fos.write(response.getBytes().getData())
|
fos.write(response.getBytes().getData())
|
||||||
@ -453,7 +454,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
|
|||||||
} catch (e: InterruptedException) {
|
} 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()
|
fos.close()
|
||||||
if (offset < size) {
|
if (offset < size) {
|
||||||
System.out.println("Requested file $target with $size bytes, but got only $offset bytes.")
|
System.out.println("Requested file $target with $size bytes, but got only $offset bytes.")
|
||||||
|
Loading…
Reference in New Issue
Block a user