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. 39
      src/node/node.go

2
src/main.go

@ -30,7 +30,7 @@ import (
) )
var ( 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) 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)

39
src/node/node.go

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