diff options
author | Karen Martikyan <kamartikyan@gmail.com> | 2020-11-08 15:50:29 +0300 |
---|---|---|
committer | Karen Martikyan <kamartikyan@gmail.com> | 2020-11-08 15:50:29 +0300 |
commit | 1d106e81636ae617ba1d4e84324584bb27c92ab8 (patch) | |
tree | 3829eba726bb6dcd85a4cd86d55c4a65ec061a11 /Duplicati/Library | |
parent | 8187f66c60cc39b7f82c65705dc1960a2f19d481 (diff) |
PR comments fixed: minor changes
Diffstat (limited to 'Duplicati/Library')
5 files changed, 33 insertions, 17 deletions
diff --git a/Duplicati/Library/Backend/Telegram/ChannelFileInfo.cs b/Duplicati/Library/Backend/Telegram/ChannelFileInfo.cs index 118a229ea..2233a9a93 100644 --- a/Duplicati/Library/Backend/Telegram/ChannelFileInfo.cs +++ b/Duplicati/Library/Backend/Telegram/ChannelFileInfo.cs @@ -6,14 +6,13 @@ namespace Duplicati.Library.Backend { public class ChannelFileInfo : IEquatable<ChannelFileInfo> { - public int MessageId { get; set; } - public long MediaDocAccessHash { get; set; } - public long DocumentId { get; set; } - public int Version { get; set; } - public long Size { get; set; } - public string Name { get; set; } - public DateTime Date { get; set; } - public long AccessHash { get; set; } + public int MessageId { get; } + public long MediaDocAccessHash { get; } + public long DocumentId { get; } + public int Version { get; } + public long Size { get; } + public string Name { get; } + public DateTime Date { get; } public ChannelFileInfo() { } diff --git a/Duplicati/Library/Backend/Telegram/Duplicati.Library.Backend.Telegram.csproj b/Duplicati/Library/Backend/Telegram/Duplicati.Library.Backend.Telegram.csproj index 29c0a6fe3..7e8c7f6c9 100644 --- a/Duplicati/Library/Backend/Telegram/Duplicati.Library.Backend.Telegram.csproj +++ b/Duplicati/Library/Backend/Telegram/Duplicati.Library.Backend.Telegram.csproj @@ -59,6 +59,10 @@ <Compile Include="Strings.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\..\AutoUpdater\Duplicati.Library.AutoUpdater.csproj"> + <Project>{7e119745-1f62-43f0-936c-f312a1912c0b}</Project> + <Name>Duplicati.Library.AutoUpdater</Name> + </ProjectReference> <ProjectReference Include="..\..\Logging\Duplicati.Library.Logging.csproj"> <Project>{d10a5fc0-11b4-4e70-86aa-8aea52bd9798}</Project> <Name>Duplicati.Library.Logging</Name> diff --git a/Duplicati/Library/Backend/Telegram/EncryptedFileSessionStore.cs b/Duplicati/Library/Backend/Telegram/EncryptedFileSessionStore.cs index 8039da11b..5f0016874 100644 --- a/Duplicati/Library/Backend/Telegram/EncryptedFileSessionStore.cs +++ b/Duplicati/Library/Backend/Telegram/EncryptedFileSessionStore.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; +using Duplicati.Library.AutoUpdater; using TLSharp.Core; namespace Duplicati.Library.Backend @@ -26,7 +27,8 @@ namespace Duplicati.Library.Backend } var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - m_teleDataPath = Path.Combine(appData, nameof(Duplicati), nameof(Telegram)); + var appName = AutoUpdateSettings.AppName; + m_teleDataPath = Path.Combine(appData, appName, nameof(Telegram)); m_password = password; Directory.CreateDirectory(m_teleDataPath); diff --git a/Duplicati/Library/Backend/Telegram/Strings.cs b/Duplicati/Library/Backend/Telegram/Strings.cs index c622f3c67..16a7c79a3 100644 --- a/Duplicati/Library/Backend/Telegram/Strings.cs +++ b/Duplicati/Library/Backend/Telegram/Strings.cs @@ -54,7 +54,6 @@ namespace Duplicati.Library.Backend #region Formats public const string TELEGRAM_FLOOD = "It's required to wait {0} seconds before continuing"; - public const string EXCEPTION_RETRY = "An exception was thrown, retrying"; public const string STARTING_EXECUTING = "Starting executing action {0}"; public const string DONE_EXECUTING = "Done executing action {0}"; public const string USER_INFO_EXC = "Exception thrown that should be shown on UI"; diff --git a/Duplicati/Library/Backend/Telegram/TelegramBackend.cs b/Duplicati/Library/Backend/Telegram/TelegramBackend.cs index 79c81b179..fe904f862 100644 --- a/Duplicati/Library/Backend/Telegram/TelegramBackend.cs +++ b/Duplicati/Library/Backend/Telegram/TelegramBackend.cs @@ -19,7 +19,7 @@ using TLRequestDeleteMessages = TeleSharp.TL.Channels.TLRequestDeleteMessages; namespace Duplicati.Library.Backend { - public class Telegram : IStreamingBackend, IBackend + public class Telegram : IStreamingBackend { private static TelegramClient m_telegramClient; private readonly EncryptedFileSessionStore m_encSessionStore; @@ -127,13 +127,18 @@ namespace Duplicati.Library.Backend public Task PutAsync(string remotename, Stream stream, CancellationToken cancelToken) { - Test(); - cancelToken.ThrowIfCancellationRequested(); SafeExecute(() => { cancelToken.ThrowIfCancellationRequested(); + + Authenticate(); + + cancelToken.ThrowIfCancellationRequested(); + var channel = GetChannel(); + cancelToken.ThrowIfCancellationRequested(); + using (var sr = new StreamReader(new StreamReadHelper(stream))) { cancelToken.ThrowIfCancellationRequested(); @@ -267,12 +272,19 @@ namespace Duplicati.Library.Backend foreach (var msg in history) { - minDate = minDate == null || minDate > msg.Id ? msg.Date : minDate; + minDate = minDate < msg.Id ? minDate : msg.Date; - if (msg.Media is TLMessageMediaDocument media) + if (msg.Media is TLMessageMediaDocument media && + media.Document is TLDocument mediaDoc) { - var mediaDoc = media.Document as TLDocument; - var fileInfo = new ChannelFileInfo(msg.Id, mediaDoc.AccessHash, mediaDoc.Id, mediaDoc.Version, mediaDoc.Size, media.Caption, DateTimeOffset.FromUnixTimeSeconds(msg.Date).UtcDateTime); + var fileInfo = new ChannelFileInfo( + msg.Id, + mediaDoc.AccessHash, + mediaDoc.Id, + mediaDoc.Version, + mediaDoc.Size, + media.Caption, + DateTimeOffset.FromUnixTimeSeconds(msg.Date).UtcDateTime); result.Add(fileInfo); } |