DevYukine / red_oxide

A CLI helping with uploading to Redacted, inspired by REDBetter
MIT License
114 stars 21 forks source link

refactor: Split `command/transcode.rs` into discrete unit testable functions #27

Open RogueOneEcho opened 6 months ago

RogueOneEcho commented 6 months ago

Notes

This PR follows on from https://github.com/DevYukine/red_oxide/pull/26

I'm new to rust and figured refactoring an existing project would be a useful exercise to learn the language - as such I'd recommend a thorough review as there may obvious things I've missed or am not aware of.

As it's a significant revision I'd recommend reviewing it commit-by-commit as each is a discrete refactoring

Notable changes

Mostly the changes are just extracting logic but these are worth noting in particular:

Previous behaviour skipped if there was no existing FLAC release, but this change ensure the specified torrent is FLAC which seemed more logical.

This avoids partial moves without resorting to cloning and seems to be the more rust-like way of doing things

Testing

For the tests to work you will need to add some .flac files to samples/flacs/[TITLE]/[file_name].flac

To get tests running in CI some Open Source / Creative Commons could be downloaded and a mock api response created for them.