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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shreyasminocha
Copy link

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
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
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() {

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