mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Fix issue with session file corruption
This commit is contained in:
parent
2ff0de667d
commit
6770f66270
|
|
@ -260,9 +260,9 @@ namespace TL
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class Peer { public abstract long ID { get; } }
|
partial class Peer { public abstract long ID { get; } }
|
||||||
partial class PeerUser { public override long ID => user_id; }
|
partial class PeerUser { public override long ID => user_id; public override string ToString() => "user " + user_id; }
|
||||||
partial class PeerChat { public override long ID => chat_id; }
|
partial class PeerChat { public override long ID => chat_id; public override string ToString() => "chat " + chat_id; }
|
||||||
partial class PeerChannel { public override long ID => channel_id; }
|
partial class PeerChannel { public override long ID => channel_id; public override string ToString() => "channel " + channel_id; }
|
||||||
|
|
||||||
partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; }
|
partial class JsonObjectValue { public override string ToString() => $"{HttpUtility.JavaScriptStringEncode(key, true)}:{value}"; }
|
||||||
partial class JsonNull { public override string ToString() => "null"; }
|
partial class JsonNull { public override string ToString() => "null"; }
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,14 @@ namespace WTelegram
|
||||||
encryptor.TransformBlock(utf8Json, 0, utf8Json.Length & ~15, output, 48);
|
encryptor.TransformBlock(utf8Json, 0, utf8Json.Length & ~15, output, 48);
|
||||||
utf8Json.AsSpan(utf8Json.Length & ~15).CopyTo(finalBlock);
|
utf8Json.AsSpan(utf8Json.Length & ~15).CopyTo(finalBlock);
|
||||||
encryptor.TransformFinalBlock(finalBlock, 0, utf8Json.Length & 15).CopyTo(output.AsMemory(48 + utf8Json.Length & ~15));
|
encryptor.TransformFinalBlock(finalBlock, 0, utf8Json.Length & 15).CopyTo(output.AsMemory(48 + utf8Json.Length & ~15));
|
||||||
File.WriteAllBytes(_pathname, output);
|
if (!File.Exists(_pathname))
|
||||||
|
File.WriteAllBytes(_pathname, output);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string tempPathname = _pathname + ".tmp";
|
||||||
|
File.WriteAllBytes(tempPathname, output);
|
||||||
|
File.Replace(tempPathname, _pathname, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal (long msgId, int seqno) NewMsg(bool isContent)
|
internal (long msgId, int seqno) NewMsg(bool isContent)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue