mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +00:00
We only need the most recent dialog in order to get the top message id.
This commit is contained in:
parent
3b01f47f38
commit
29b963ec25
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user