Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Martikyan <kamartikyan@gmail.com>2020-11-08 22:14:39 +0300
committerKaren Martikyan <kamartikyan@gmail.com>2020-11-08 22:14:39 +0300
commit1bc6e20a5794a305b354e5b85c427f1963fb4631 (patch)
tree22ed42a64fda5416cd5eef01664fa25cb7e33816 /Duplicati/Library/Backend
parent1d106e81636ae617ba1d4e84324584bb27c92ab8 (diff)
Fixed possible bug connected with retrieval more than 100 messages from a channel
Diffstat (limited to 'Duplicati/Library/Backend')
-rw-r--r--Duplicati/Library/Backend/Telegram/TelegramBackend.cs24
1 files changed, 8 insertions, 16 deletions
diff --git a/Duplicati/Library/Backend/Telegram/TelegramBackend.cs b/Duplicati/Library/Backend/Telegram/TelegramBackend.cs
index fe904f862..380cd4f7f 100644
--- a/Duplicati/Library/Backend/Telegram/TelegramBackend.cs
+++ b/Duplicati/Library/Backend/Telegram/TelegramBackend.cs
@@ -246,34 +246,28 @@ namespace Duplicati.Library.Backend
var inputPeerChannel = new TLInputPeerChannel {ChannelId = channel.Id, AccessHash = channel.AccessHash.Value};
var result = new List<ChannelFileInfo>();
- var cMinId = (int?)0;
+ var oldMinDate = 0;
+ var newMinDate = (int?)null;
- while (cMinId != null)
+ while (oldMinDate != newMinDate)
{
- var newCMinId = RetrieveMessages(inputPeerChannel, result, cMinId.Value);
- if (newCMinId == cMinId)
- {
- break;
- }
-
- cMinId = newCMinId;
+ oldMinDate = newMinDate ?? 0;
+ RetrieveMessages(inputPeerChannel, result, oldMinDate);
+ newMinDate = result.Min(cfi => (int)cfi.Date.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
}
result = result.Distinct().ToList();
return result;
}
- private int? RetrieveMessages(TLInputPeerChannel inputPeerChannel, List<ChannelFileInfo> result, int maxDate)
+ private void RetrieveMessages(TLInputPeerChannel inputPeerChannel, List<ChannelFileInfo> result, int offsetDate)
{
EnsureConnected();
- var absHistory = m_telegramClient.GetHistoryAsync(inputPeerChannel, offsetDate: maxDate).GetAwaiter().GetResult();
+ var absHistory = m_telegramClient.GetHistoryAsync(inputPeerChannel, offsetDate: offsetDate).GetAwaiter().GetResult();
var history = ((TLChannelMessages)absHistory).Messages.OfType<TLMessage>();
- var minDate = (int?)null;
foreach (var msg in history)
{
- minDate = minDate < msg.Id ? minDate : msg.Date;
-
if (msg.Media is TLMessageMediaDocument media &&
media.Document is TLDocument mediaDoc)
{
@@ -289,8 +283,6 @@ namespace Duplicati.Library.Backend
result.Add(fileInfo);
}
}
-
- return minDate;
}
public IList<ICommandLineArgument> SupportedCommands { get; } = new List<ICommandLineArgument>