This commit is contained in:
Leijurv 2018-03-08 22:18:53 +00:00 committed by GitHub
commit de9ffb0fd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -31,7 +31,7 @@ compileKotlin {
dependencies {
compile('com.github.badoualy:kotlogram:666a81ef9d6707f117a3fecc2d21c91d51c7d075') {
compile('com.github.badoualy:kotlogram:1.0.0-RC2') {
exclude module: 'slf4j-simple'
}
compile 'org.xerial:sqlite-jdbc:3.16.1'

View File

@ -111,6 +111,7 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
System.out.println("Downloading most recent dialogs... ")
var max_message_id = 0
val dialogs = client!!.messagesGetDialogs(
true,
0,
0,
TLInputPeerEmpty(),
@ -398,8 +399,8 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
}
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
fun downloadFile(targetFilename: String, size: Int, dcId: Int, id: Long, accessHash: Long) {
val loc = TLInputDocumentFileLocation(id, accessHash)
fun downloadFile(targetFilename: String, size: Int, dcId: Int, id: Long, accessHash: Long, version: Int) {
val loc = TLInputDocumentFileLocation(id, accessHash, version)
downloadFileFromDc(targetFilename, loc, dcId, size)
}
@ -438,6 +439,9 @@ class DownloadManager(internal var client: TelegramClient?, p: DownloadProgressI
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
System.out.println("400 error code")
e.printStackTrace()
System.out.println("400 error code")
return false
} else {
throw e

View File

@ -99,7 +99,7 @@ open class DocumentFileManager(msg: TLMessage, user: UserManager, client: Telegr
@Throws(RpcErrorException::class, IOException::class, TimeoutException::class)
override fun download(): Boolean {
if (doc != null) {
DownloadManager.downloadFile(targetPathAndFilename, size, doc!!.getDcId(), doc!!.getId(), doc!!.getAccessHash())
DownloadManager.downloadFile(targetPathAndFilename, size, doc!!.getDcId(), doc!!.getId(), doc!!.getAccessHash(), doc!!.getVersion())
}
return true
}