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

We only need the most recent dialog in order to get the top message id.

This commit is contained in:
Fabian Schlenz 2016-07-04 11:04:35 +02:00
parent 3b01f47f38
commit 29b963ec25
2 changed files with 4 additions and 10 deletions

View File

@ -16,7 +16,7 @@ class Config {
public static final String FILE_NAME_DB = "database.sqlite";
public static final String FILE_FILES_BASE = "files";
public static final String FILE_STICKER_BASE = "stickers";
public static final int FILE_DOWNLOAD_BLOCK_SIZE = 10*1024*1024;
public static final int DELAY_AFTER_GET_MESSAGES = 200;

View File

@ -35,21 +35,15 @@ class DownloadManager {
}
public void downloadMessages(Integer limit) throws RpcErrorException, IOException {
System.out.print("Downloading dialogs... ");
TLAbsDialogs dialogs = client.messagesGetDialogs(
System.out.println("Downloading most recent dialog... ");
int max_message_id = client.messagesGetDialogs(
0,
0,
new TLInputPeerEmpty(),
100);
System.out.println("Got " + dialogs.getDialogs().size() + " dialogs.");
int max_message_id = -1;
for(TLAbsDialog dialog : dialogs.getDialogs()) {
max_message_id = Math.max(max_message_id, dialog.getTopMessage());
}
1).getDialogs().get(0).getTopMessage();
System.out.println("Top message ID is " + max_message_id);
int max_database_id = db.getTopMessageID();
System.out.println("Top message ID in database is " + max_database_id);
if (limit != null) {
System.out.println("Limit is set to " + limit);
max_database_id = Math.max(max_database_id, max_message_id-limit);