diff --git a/.github/dev.yml b/.github/dev.yml index ac626b6..e355e5d 100644 --- a/.github/dev.yml +++ b/.github/dev.yml @@ -2,7 +2,7 @@ pr: none trigger: - master -name: 1.7.6-dev.$(Rev:r) +name: 1.7.7-dev.$(Rev:r) pool: vmImage: ubuntu-latest diff --git a/src/Session.cs b/src/Session.cs index 9fe35fd..1a675cb 100644 --- a/src/Session.cs +++ b/src/Session.cs @@ -87,14 +87,13 @@ namespace WTelegram encryptor.TransformBlock(utf8Json, 0, utf8Json.Length & ~15, output, 48); utf8Json.AsSpan(utf8Json.Length & ~15).CopyTo(finalBlock); encryptor.TransformFinalBlock(finalBlock, 0, utf8Json.Length & 15).CopyTo(output.AsMemory(48 + utf8Json.Length & ~15)); - if (!File.Exists(_pathname)) - File.WriteAllBytes(_pathname, output); - else lock (this) - { - string tempPathname = _pathname + ".tmp"; - File.WriteAllBytes(tempPathname, output); - File.Replace(tempPathname, _pathname, null); - } + string tempPathname = _pathname + ".tmp"; + lock (this) + { + File.WriteAllBytes(tempPathname, output); + File.Delete(_pathname); + File.Move(tempPathname, _pathname); + } } } } \ No newline at end of file