pyed / transmission-telegram

Control your Transmission through a Telegram bot
Apache License 2.0
288 stars 47 forks source link

Crash trying to delete #2

Closed FrancYescO closed 7 years ago

FrancYescO commented 7 years ago

I just tried a "deldata 1" on an unmagnetized torrent (was shown with a red bar and with the hash in the web GUI) and i got this crash

panic: runtime error: index out of range

goroutine 202 [running]: panic(0x667400, 0xc420012100) /usr/local/go/src/runtime/panic.go:500 +0x1a1 main.head(0x26b45191, 0xc420380000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4204460b0, 0x0, ...) /root/go/src/github.com/pyed/transmission-telegram/transmission-telegram.go:434 +0xe92 created by main.main /root/go/src/github.com/pyed/transmission-telegram/transmission-telegram.go:254 +0x78b

After a restart of the bin I got the message from the bot that the torrent was deleted with his data

pyed commented 7 years ago

I see that the panic is pointing to the head function, what I believe happened is that you sent the command head and it hug half way through then you sent deldata 1, head knew that there's at least one torrent and it tried to access it, but deldata 1 was faster.

FrancYescO commented 7 years ago

yep you are probably right, here the full conv with the bot: http://i.imgur.com/GyNvi8N.png

pyed commented 7 years ago

actually it is a bug, it's not about timing, it's just that head will always expect to find at least 1 torrent if it get executed before deleting the last one, because it keeps updating the message, it should check with every iteration to make sure that we have at least one torrent.

FrancYescO commented 7 years ago

what about just stop updating the old message if another one received? this will also allow to avoid update the message endless

pyed commented 7 years ago

thank you!