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. 22
      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)

22
src/node/node.go

@ -774,10 +774,11 @@ func (node *Node) receive() {
// accepted
// append provided bytes to the file
err = acceptedFile.Open()
if err != nil {
panic(err)
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,9 +815,11 @@ func (node *Node) receive() {
fmt.Printf("\n[File] fully received \"%s\" -- %d bytes", acceptedFile.Name, acceptedFile.Size)
}
err = acceptedFile.Open()
if err != nil {
panic(err)
if acceptedFile.Handler == nil {
err = acceptedFile.Open()
if err != nil {
panic(err)
}
}
// remove this file from the pool

Loading…
Cancel
Save