mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
DownloadFileAsync: don't use stream.Position if !CanSeek
This commit is contained in:
parent
6f3c8732ec
commit
0ad7d696a5
2
.github/dev.yml
vendored
2
.github/dev.yml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
pr: none
|
pr: none
|
||||||
trigger: [ master ]
|
trigger: [ master ]
|
||||||
|
|
||||||
name: 3.6.5-dev.$(Rev:r)
|
name: 3.6.6-dev.$(Rev:r)
|
||||||
|
|
||||||
pool:
|
pool:
|
||||||
vmImage: ubuntu-latest
|
vmImage: ubuntu-latest
|
||||||
|
|
|
||||||
2
FAQ.md
2
FAQ.md
|
|
@ -235,7 +235,7 @@ In particular, it will detect and handle automatically and properly the various
|
||||||
* 2FA password required (your Config needs to provide "password")
|
* 2FA password required (your Config needs to provide "password")
|
||||||
* Email registration procedure required (your Config needs to provide "email", "email_verification_code")
|
* Email registration procedure required (your Config needs to provide "email", "email_verification_code")
|
||||||
* Account registration/sign-up required (your Config needs to provide "first_name", "last_name")
|
* Account registration/sign-up required (your Config needs to provide "first_name", "last_name")
|
||||||
* Request to resend the verification code through alternate ways like SMS (if your Config answer an empty "verification_code" initially)
|
* Request to resend the verification code through alternate ways (if your Config answer an empty "verification_code" initially)
|
||||||
* Transient failures, slowness to respond, wrong code/password, checks for encryption key safety, etc..
|
* Transient failures, slowness to respond, wrong code/password, checks for encryption key safety, etc..
|
||||||
|
|
||||||
Contrary to TLSharp, WTelegramClient supports MTProto v2.0 (more secured), transport obfuscation, protocol security checks, MTProto [Proxy](EXAMPLES.md#proxy), real-time updates, multiple DC connections, API documentation in Intellisense...
|
Contrary to TLSharp, WTelegramClient supports MTProto v2.0 (more secured), transport obfuscation, protocol security checks, MTProto [Proxy](EXAMPLES.md#proxy), real-time updates, multiple DC connections, API documentation in Intellisense...
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ namespace WTelegram
|
||||||
var client = dc_id == 0 ? this : await GetClientForDC(dc_id, true);
|
var client = dc_id == 0 ? this : await GetClientForDC(dc_id, true);
|
||||||
using var writeSem = new SemaphoreSlim(1);
|
using var writeSem = new SemaphoreSlim(1);
|
||||||
bool canSeek = outputStream.CanSeek;
|
bool canSeek = outputStream.CanSeek;
|
||||||
long streamStartPos = outputStream.Position;
|
long streamStartPos = canSeek ? outputStream.Position : 0;
|
||||||
long fileOffset = 0, maxOffsetSeen = 0;
|
long fileOffset = 0, maxOffsetSeen = 0;
|
||||||
long transmitted = 0;
|
long transmitted = 0;
|
||||||
var tasks = new Dictionary<long, Task>();
|
var tasks = new Dictionary<long, Task>();
|
||||||
|
|
@ -373,7 +373,7 @@ namespace WTelegram
|
||||||
await writeSem.WaitAsync();
|
await writeSem.WaitAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (streamStartPos + offset != outputStream.Position) // if we're about to write out of order
|
if (canSeek && streamStartPos + offset != outputStream.Position) // if we're about to write out of order
|
||||||
{
|
{
|
||||||
await outputStream.FlushAsync(); // async flush, otherwise Seek would do a sync flush
|
await outputStream.FlushAsync(); // async flush, otherwise Seek would do a sync flush
|
||||||
outputStream.Seek(streamStartPos + offset, SeekOrigin.Begin);
|
outputStream.Seek(streamStartPos + offset, SeekOrigin.Begin);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue