Browse Source

Less syscalls to open files on the receiving end

main v2.3.1
Unbewohnte 3 years ago
parent
commit
2548fa68e7
  1. 2
      src/main.go
  2. 10
      src/node/node.go

2
src/main.go

@ -30,7 +30,7 @@ import (
)
var (
VERSION string = "v2.3.0"
VERSION string = "v2.3.1"
versionInformation string = fmt.Sprintf("ftu %s\nfile transferring utility\n\nCopyright (C) 2021,2022 Kasyanov Nikolay Alexeevich (Unbewohnte (me@unbewohnte.xyz))\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions; type \"ftu -l\" for details.\n", VERSION)

10
src/node/node.go

@ -774,11 +774,12 @@ func (node *Node) receive() {
// accepted
// append provided bytes to the file
if acceptedFile.Handler == nil {
err = acceptedFile.Open()
if err != nil {
panic(err)
}
}
fileBytes := fileBytesBuffer.Bytes()
@ -788,11 +789,6 @@ func (node *Node) receive() {
}
acceptedFile.SentBytes += uint64(wrote)
node.transferInfo.Receiving.ReceivedBytes += uint64(wrote)
err = acceptedFile.Close()
if err != nil {
panic(err)
}
}
}
@ -819,10 +815,12 @@ func (node *Node) receive() {
fmt.Printf("\n[File] fully received \"%s\" -- %d bytes", acceptedFile.Name, acceptedFile.Size)
}
if acceptedFile.Handler == nil {
err = acceptedFile.Open()
if err != nil {
panic(err)
}
}
// remove this file from the pool
node.transferInfo.Receiving.AcceptedFiles = append(node.transferInfo.Receiving.AcceptedFiles[:index], node.transferInfo.Receiving.AcceptedFiles[index+1:]...)

Loading…
Cancel
Save