fix small file transfer, closes #104 (#105)

This commit is contained in:
Evgeny Poberezkin
2021-09-25 10:09:49 +01:00
committed by GitHub
parent 2bf6d08a16
commit e9180ed0dc
3 changed files with 31 additions and 1 deletions
+6 -1
View File
@@ -1321,7 +1321,12 @@ createRcvFileChunk st RcvFileTransfer {fileId, fileInvitation = FileInvitation {
getLastChunkNo db = do
ns <- DB.query db "SELECT chunk_number FROM rcv_file_chunks WHERE file_id = ? ORDER BY chunk_number DESC LIMIT 1" (Only fileId)
pure $ case map fromOnly ns of
[] -> if chunkNo == 1 then RcvChunkOk else RcvChunkError
[]
| chunkNo == 1 ->
if chunkSize >= fileSize
then RcvChunkFinal
else RcvChunkOk
| otherwise -> RcvChunkError
n : _
| chunkNo == n -> RcvChunkDuplicate
| chunkNo == n + 1 ->