about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-29 17:29:37 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-29 17:29:37 +0100
commita73bdecc9111bfd377b26b069d989030eb767d1f (patch)
tree9585ae5dc614ec2f6872a32b8c1289c78d43fe9a
parent8cdf0a47072cc0f223a73da96833dc31028835fa (diff)
downloadchawan-a73bdecc9111bfd377b26b069d989030eb767d1f.tar.gz
pager: fix broken writeToFile
-rw-r--r--src/io/dynstream.nim3
-rw-r--r--src/local/pager.nim6
2 files changed, 4 insertions, 5 deletions
diff --git a/src/io/dynstream.nim b/src/io/dynstream.nim
index 1b0f8807..8032f5ec 100644
--- a/src/io/dynstream.nim
+++ b/src/io/dynstream.nim
@@ -44,6 +44,9 @@ proc sendDataLoop*(s: DynStream; buffer: pointer; len: int) =
     if n == len:
       break
 
+proc sendDataLoop*(s: DynStream; buffer: openArray[uint8]) {.inline.} =
+  s.sendDataLoop(unsafeAddr buffer[0], buffer.len)
+
 proc sendDataLoop*(s: DynStream; buffer: openArray[char]) {.inline.} =
   s.sendDataLoop(unsafeAddr buffer[0], buffer.len)
 
diff --git a/src/local/pager.nim b/src/local/pager.nim
index 6e9ac0dd..5c639a20 100644
--- a/src/local/pager.nim
+++ b/src/local/pager.nim
@@ -1348,11 +1348,7 @@ proc writeToFile(istream: SocketStream; outpath: string): bool =
     let n = istream.recvData(buffer)
     if n == 0:
       break
-    if ps.sendData(buffer.toOpenArray(0, n - 1)) < n:
-      ps.sclose()
-      return false
-    if n < buffer.len:
-      break
+    ps.sendDataLoop(buffer.toOpenArray(0, n - 1))
   ps.sclose()
   true