Conversation
crates/librqbit/src/watch.rs
Outdated
| None | ||
| } | ||
| }) | ||
| .map(|(add_torrent, path)| { |
There was a problem hiding this comment.
Instead of let _results = map().collect() (which allocates needlessly and creates an unused variable) you can use ether a for loop or for_each
There was a problem hiding this comment.
makes sense, done
crates/librqbit/src/watch.rs
Outdated
| .paths | ||
| .iter() | ||
| .filter_map(|path| match path.extension() { | ||
| Some(x) if x.to_str() == Some("torrent") => match read_and_validate_torrent(path) { |
There was a problem hiding this comment.
it would probably be a bit shorter an more efficient if you do
match path.extension().and_then(|e| e.to_str())? {
"torrent" => ...,
"magnet" => ...,
}There was a problem hiding this comment.
right, probably you don't want ? as if by any reason a file without extension would land in the watch folder you would return and not process the rest of files, wouldn't it?
Changed it to match path.extension().and_then(|e| e.to_str()) { ...}
There was a problem hiding this comment.
As it's part of filter_map, the ? would only apply to the callback, not the outer function, so it should work
There was a problem hiding this comment.
Ok learned something new, thanks, i will change that
There was a problem hiding this comment.
Oh I somehow I forgot that it was inside a closure, that's why, it returns from there.
Done
3fc5caa to
0413ed7
Compare
0413ed7 to
cc771f8
Compare
Currently only
.torrentfiles are being considered when watching a folder.This PR adds extends that functionality to
.magnetfiles too.