|
|
|
@ -223,8 +223,8 @@ func (node *Node) Start() {
|
|
|
|
|
// and wait for it to be ready again
|
|
|
|
|
if node.State.AllowedToTransfer && node.TransferInfo.Ready { |
|
|
|
|
err = sendPiece(file, node.Net.Conn, node.Net.EncryptionKey) |
|
|
|
|
if err != nil { |
|
|
|
|
if err == ErrorSentAll { |
|
|
|
|
switch err { |
|
|
|
|
case ErrorSentAll: |
|
|
|
|
// the file has been sent fully
|
|
|
|
|
fileIDBuff := new(bytes.Buffer) |
|
|
|
|
err = binary.Write(fileIDBuff, binary.BigEndian, file.ID) |
|
|
|
@ -253,13 +253,15 @@ func (node *Node) Start() {
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
node.State.Stopped = true |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
case nil: |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
node.State.Stopped = true |
|
|
|
|
|
|
|
|
|
fmt.Printf("An error occured when sending a piece of \"%s\": %s\n", file.Name, err) |
|
|
|
|
fmt.Printf("An error occured while sending a piece of \"%s\": %s\n", file.Name, err) |
|
|
|
|
panic(err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
node.TransferInfo.Ready = false |
|
|
|
|
} |
|
|
|
|