diff --git a/src/Common/Library.fs b/src/Common/Library.fs index fe55d12..78c517a 100644 --- a/src/Common/Library.fs +++ b/src/Common/Library.fs @@ -634,6 +634,8 @@ module Query = |> function it -> $" ORDER BY {it}" +#nowarn "FS3511" // "let rec" is not statically compilable + open System.IO.Pipelines /// Functions that manipulate PipeWriters @@ -648,8 +650,7 @@ module PipeWriter = let writeString (writer: PipeWriter) (text: string) = backgroundTask { try let! writeResult = writer.WriteAsync(Encoding.UTF8.GetBytes text) - let! flushResult = writer.FlushAsync() - return not (writeResult.IsCompleted || flushResult.IsCompleted) + return not writeResult.IsCompleted with :? System.ObjectDisposedException -> return false } @@ -659,19 +660,20 @@ module PipeWriter = /// true if the pipe is still open, false if not [] let writeStrings writer items = backgroundTask { - let rec writeNext docs idx = backgroundTask { - match items |> Seq.tryItem idx with + let theItems = Seq.cache items + let rec writeNext idx = backgroundTask { + match theItems |> Seq.tryItem idx with | Some item -> if idx > 0 then let! _ = writeString writer "," () match! writeString writer item with - | true -> return! writeNext docs (idx + 1) + | true -> return! writeNext (idx + 1) | false -> return false | None -> return true } let! _ = writeString writer "[" - let! isCleanFinish = writeNext items 0 + let! isCleanFinish = writeNext 0 if isCleanFinish then let! _ = writeString writer "]" ()