Repository: dotnet/runtime
File: src/libraries/System.IO.Compression.ZipFile/src/System/IO/Compression/ZipFileExtensions.ZipArchiveEntry.Extract.cs (C#)

Code before:
                }

                // Move the temporary file to the destination only after successful extraction
                if (tempPath is not null)
                {
                    File.Move(tempPath, destinationFileName, overwrite: true);
                }

                ExtractToFileFinalize(source, destinationFileName);
            }
            catch
            {
                // Clean up the temporary file if extraction failed
                if (tempPath is not null && File.Exists(tempPath))
                {
                    // Ignore exceptions during cleanup; the original exception is more important
                    try { File.Delete(tempPath); } catch (IOException) { } catch (UnauthorizedAccessException) { }
                }
                throw;
            }
        }

        private static void ExtractToFileInitialize(ZipArchiveEntry source, string destinationFileName, bool overwrite, out FileStreamOptions fileStreamOptions)
        {
            ExtractToFileInitialize(source, destinationFileName, overwrite, useAsync: false, out fileStreamOptions);
        }

        private static void ExtractToFileInitialize(ZipArchiveEntry source, string destinationFileName, bool overwrite, bool useAsync, out FileStreamOptions fileStreamOptions)
        {
            ArgumentNullException.ThrowIfNull(source);
            ArgumentNullException.ThrowIfNull(destinationFileName);

            fileStreamOptions = new()
            {
                Access = FileAccess.Write,
                Mode = overwrite ? FileMode.Create : FileMode.CreateNew,
                Share = FileShare.None,
                BufferSize = ZipFile.FileStreamBufferSize,
                Options = useAsync ? FileOptions.Asynchronous : FileOptions.None
            };

            const UnixFileMode OwnershipPermissions =
                UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute |
                UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute |
                UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;

            // Restore Unix permissions.
            // For security, limit to ownership permissions, and respect umask (through UnixCreateMode).
            // We don't apply UnixFileMode.None because .zip files created on Windows and .zip files created
            // with previous versions of .NET don't include permissions.
            UnixFileMode mode = (UnixFileMode)(source.ExternalAttributes >> 16) & OwnershipPermissions;

Review comment (refactor):
I think we should remove this one and call the new method with `useAsync` on in any existing callsites

Code after:
                }

                // Move the temporary file to the destination only after successful extraction
                if (tempPath is not null)
                {
                    File.Move(tempPath, destinationFileName, overwrite: true);
                }

                ExtractToFileFinalize(source, destinationFileName);
            }
            catch
            {
                // Clean up the temporary file if extraction failed
                if (tempPath is not null && File.Exists(tempPath))
                {
                    // Ignore exceptions during cleanup; the original exception is more important
                    try { File.Delete(tempPath); } catch { }
                }
                throw;
            }
        }

        private static void ExtractToFileInitialize(ZipArchiveEntry source, string destinationFileName, bool overwrite, bool useAsync, out FileStreamOptions fileStreamOptions)
        {
            ArgumentNullException.ThrowIfNull(source);
            ArgumentNullException.ThrowIfNull(destinationFileName);

            fileStreamOptions = new()
            {
                Access = FileAccess.Write,
                Mode = overwrite ? FileMode.Create : FileMode.CreateNew,
                Share = FileShare.None,
                BufferSize = ZipFile.FileStreamBufferSize,
                Options = useAsync ? FileOptions.Asynchronous : FileOptions.None
            };

            const UnixFileMode OwnershipPermissions =
                UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute |
                UnixFileMode.GroupRead | UnixFileMode.GroupWrite | UnixFileMode.GroupExecute |
                UnixFileMode.OtherRead | UnixFileMode.OtherWrite | UnixFileMode.OtherExecute;

            // Restore Unix permissions.
            // For security, limit to ownership permissions, and respect umask (through UnixCreateMode).
            // We don't apply UnixFileMode.None because .zip files created on Windows and .zip files created
            // with previous versions of .NET don't include permissions.
            UnixFileMode mode = (UnixFileMode)(source.ExternalAttributes >> 16) & OwnershipPermissions;
            if (mode != UnixFileMode.None && !OperatingSystem.IsWindows())
            {
                fileStreamOptions.UnixCreateMode = mode;
            }
        }