altugbakan / rs-tftpd

TFTP Server Daemon implemented in Rust
https://crates.io/crates/tftpd
MIT License
51 stars 14 forks source link

feat: make cli option to prevent file removal after receiving errors.… #26

Closed mykola2312 closed 1 month ago

mykola2312 commented 1 month ago

So, I was tinkering with some embedded device which had only busybox and TFTP client. That time I realized I need minimal but feature-able TFTP server, so I looked up and found your project. Everything was going OK until I stumbled upon troubles with dumping block devices. You see, when program reaches end of available block device, like /dev/mtdblock4, it will throw IO error instead of usual EOF, and when error happens the TFTP daemon deletes file. This is not what I wanted and I realized there is no way to disable file deletion. In the end of the day dump was OK and file deletion is unnecessary in this case.

In this PR I made Config / ClientConfig parse --dont-clean option, which then affects value of clean_on_error variable in Config / ClientConfig structs. When instantiating Worker, there is new param which is clean_on_error. I had to pass it into Worker struct, otherwise I would be stuck with global variable or something.

I also changed tests and checked them to work with new parameter.

Best regards,

mykola2312 commented 1 month ago

Done

altugbakan commented 1 month ago

I think the tests still use the old flag, that's why it is failing

mykola2312 commented 1 month ago

Damn I forgot to update tests

Mart-Bogdan commented 1 month ago

Why this is hidden by command line flag? Shouldn't it be default behavior to not delete files when user was downloading, not actually deleting stuff?

altugbakan commented 1 month ago

This is done when receiving a file fails, so a client sending a file and if there's an error, a cleanup happens, since the file is not complete. This is actually the behaviour of most TFTP servers.