Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --output to be a directory #546

Merged
merged 5 commits into from
Jan 22, 2025
Merged

Conversation

shreyasminocha
Copy link
Contributor

Currently, when the --output flag to torrent create is a directory, imdl errors out with "error: Output path already exists".

With this change, it will create a torrent file with the default name, but in the specified directory.

$ mkdir out
$ imdl torrent create src --output out
[1/3] 🧿 Searching `src` for files…
[2/3] 🧮 Hashing pieces…
[3/3] 💾 Writing metainfo to `out/src.torrent`…
✨✨ Done! ✨✨
$ ls out
src.torrent

Resolves #525

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This should re-use CreateContent::torrent_path to set the filename, and also needs a test.

@shreyasminocha
Copy link
Contributor Author

This should re-use CreateContent::torrent_path to set the filename

I tried that, but it seems to return an absolute path, and path.join(absolute_path) effectively just returns absolute_path. I could edit torrent_path to return the relative path "{name}.torrent" if you prefer.

@shreyasminocha
Copy link
Contributor Author

I added a test, but it's currently failing because path.is_dir() returns false in the test env. Not sure what's up with that; I could be misunderstanding how temptree works.

@casey
Copy link
Owner

casey commented Dec 28, 2024

I believe this check is failing:

if !self.force && path.exists() {

@shreyasminocha
Copy link
Contributor Author

This should be ready for review, unless you'd like me to change torrent_path as described in #546 (comment)! Let me know if this needs to be rebased.

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@casey casey enabled auto-merge (squash) January 22, 2025 00:28
@casey casey merged commit 020086f into casey:master Jan 22, 2025
8 checks passed
@shreyasminocha shreyasminocha deleted the output-dir branch January 22, 2025 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for output directories
2 participants