Browse Source

[Node] Invalid transfer info printing is >>|FIXED|<<

main v2.2.2
Unbewohnte 3 years ago
parent
commit
4d12a15a58
  1. 2
      src/main.go
  2. 29
      src/node/node.go

2
src/main.go

@ -30,7 +30,7 @@ import (
)
var (
VERSION string = "v2.2.1"
VERSION string = "v2.2.2"
versionInformation string = fmt.Sprintf("ftu %s\n\nCopyright (C) 2021,2022 Kasyanov Nikolay Alexeevich (Unbewohnte (https://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)

29
src/node/node.go

@ -315,6 +315,10 @@ func (node *Node) send() {
break
}
if !node.verboseOutput {
go node.printTransferInfo(time.Second)
}
// receive incoming packets and decrypt them if necessary
incomingPacket, ok := <-node.packetPipe
if !ok {
@ -395,12 +399,13 @@ func (node *Node) send() {
node.transferInfo.Sending.SentBytes += fileToSend.Size
node.transferInfo.Sending.InTransfer = false
if node.verboseOutput {
fmt.Printf("\n[File] receiver already has \"%s\"", fileToSend.Name)
}
}
}
}
// Transfer section
@ -411,7 +416,6 @@ func (node *Node) send() {
Header: protocol.HeaderDone,
})
fmt.Printf("\nTransfer ended successfully")
node.stopped = true
continue
@ -451,10 +455,6 @@ func (node *Node) send() {
continue
}
if !node.verboseOutput {
go node.printTransferInfo(time.Second)
}
// if allowed to transfer and the other node is ready to receive packets - send one piece
// and wait for it to be ready again
if node.transferInfo.Sending.AllowedToTransfer && node.transferInfo.Sending.CanSendBytes && node.transferInfo.Sending.InTransfer {
@ -544,6 +544,10 @@ func (node *Node) receive() {
break
}
if !node.verboseOutput && node.transferInfo.Receiving.ReceivedBytes != 0 {
go node.printTransferInfo(time.Second)
}
// receive incoming packets and decrypt them if necessary
incomingPacket, ok := <-node.packetPipe
if !ok {
@ -718,6 +722,13 @@ func (node *Node) receive() {
node.mutex.Lock()
node.transferInfo.Receiving.AcceptedFiles = append(node.transferInfo.Receiving.AcceptedFiles, file)
node.mutex.Unlock()
err = protocol.SendPacket(node.netInfo.Conn, protocol.Packet{
Header: protocol.HeaderReady,
})
if err != nil {
panic(err)
}
}
existingFileHandler.Close()
@ -727,7 +738,6 @@ func (node *Node) receive() {
node.mutex.Lock()
node.transferInfo.Receiving.AcceptedFiles = append(node.transferInfo.Receiving.AcceptedFiles, file)
node.mutex.Unlock()
}
err = protocol.SendPacket(node.netInfo.Conn, protocol.Packet{
Header: protocol.HeaderReady,
@ -735,6 +745,7 @@ func (node *Node) receive() {
if err != nil {
panic(err)
}
}
case protocol.HeaderFileBytes:
// check if this file has been accepted to receive
@ -855,10 +866,6 @@ func (node *Node) receive() {
fmt.Printf("\n%s disconnected", node.netInfo.Conn.RemoteAddr())
}
if !node.verboseOutput && node.transferInfo.Receiving.ReceivedBytes != 0 {
go node.printTransferInfo(time.Second)
}
}
}

Loading…
Cancel
Save