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

convert: add option to symlink or hardlink instead of copying #3348

Merged
merged 4 commits into from
Aug 21, 2019

Conversation

Vexatos
Copy link
Contributor

@Vexatos Vexatos commented Aug 20, 2019

This is an updated version of #2326 and 7d26639, resolving merge conflicts and addressing the comments on that PR. Based on proposal in #2324.
Credit goes to @kierdavis for the original PR.

Closes #2326 if merged.

As proposed in beetbox#2324.

Updated commit from beetbox#2326.

Co-authored-by: Vexatos <[email protected]>
Overrides the --link option.

As proposed in beetbox#2324.
@Vexatos Vexatos changed the title convert: add option to symlink instead of copying convert: add option to symlink or hardlink instead of copying Aug 20, 2019
@Vexatos
Copy link
Contributor Author

Vexatos commented Aug 20, 2019

Added -H and --hardlink flags as well as the hardlink option to use hardlinks instead of symlinks. This is very useful for those who use convert to shrink their lossless files for putting it on phones, for instance, since copying to phones while following symlinks can sometimes be a hassle.

Fixed flag precedence of link and hardlink over their options.
Fixed formatting issue.
Copy link
Member

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

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

Awesome; thanks for picking this up! Here are some suggestions.

self._log.info(u'Linking {0}',
util.displayable_path(item.path))
util.link(original, converted)
linked = True
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can hoist this assignment out and just write linked = link or hardlink?

Copy link
Member

Choose a reason for hiding this comment

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

Also, is there any way to factor out some of the logic here so there's less duplicated code? For example, perhaps we could assign to a string to switch between 'ln' and 'ln -s' but only keeping one copy of the _log.info line.

Copy link
Contributor Author

@Vexatos Vexatos Aug 21, 2019

Choose a reason for hiding this comment

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

link and hardlink are set globally for the entire command. The way it's done here, copying album art still occurs for files that actually were converted, and is only skipped on those that are linked. I could, however, move it right below the else below the should_transcode check.

beetsplug/convert.py Show resolved Hide resolved
beetsplug/convert.py Outdated Show resolved Hide resolved
docs/changelog.rst Show resolved Hide resolved
docs/plugins/convert.rst Outdated Show resolved Hide resolved
docs/plugins/convert.rst Show resolved Hide resolved
@Vexatos
Copy link
Contributor Author

Vexatos commented Aug 21, 2019

Thank you for the suggestions. I reduced the amount of duplicate code now.

Also slightly reworded documentation.
@sampsyo
Copy link
Member

sampsyo commented Aug 21, 2019

Yay! Looks great! Thanks for tackling this.

@sampsyo sampsyo merged commit 68e1093 into beetbox:master Aug 21, 2019
@kierdavis
Copy link
Contributor

Thanks @Vexatos!

And sorry about abandoning this before; it got pushed down my todo list once my use case for it disappeared :(

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.

4 participants