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

Add log message on verbose, when beets renames destination file during move. #4924

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

Conversation

fleur
Copy link

@fleur fleur commented Sep 24, 2023

Description

First step in fix of #2895. Add log message on verbose, when beets renames destination file during move. The issue says it may be trickier than it looks. It did not seem tricky, so only doing the first step suggested, to see if I missed something.

To Do

  • Documentation is not needed since functional behavior is not changing.
  • Changelog
  • Tests are not needed because there are already tests in test/test_files.py that exercise the code path that pass.

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.

This seems like a nice idea! Here are some suggestions.

beets/library.py Outdated
Comment on lines 862 to 863
'File already exists at dest, changing final path slightly, '
"to be unique, from '{}', to '{}'.",
Copy link
Member

Choose a reason for hiding this comment

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

Just a suggestion to slightly simplify the wording here… how about this?

File exists at {}. Avoiding conflict with new name: {}

dest = util.unique_path(dest)
log.debug(
Copy link
Member

Choose a reason for hiding this comment

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

I think you may need a if dest != old_dest here. This may also need some careful testing to make sure it doesn't fire spuriously when these point to the same path but are just normalized differently… hopefully that doesn't happen, but a few test runs should reveal the answer!

Copy link
Author

Choose a reason for hiding this comment

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

Normalized differently? I admit I had a big assumption that the stuff passed in would be comparable. Should both incoming paths go through util.bytestring_path, would that normalize them the same way? I'm obviously not familiar enough with the codebase to understand where paths might be normalized different ways. I'll dig further.

Copy link
Author

Choose a reason for hiding this comment

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

If you have any specific suggestions of test runs, and have the time to, please let me know. All tests pass, so I'm assuming you mean something outside of those.

Copy link
Member

Choose a reason for hiding this comment

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

About being "normalized differently," I'm just thinking about all the various ways in which different paths can refer to the same file. For example, os.path.normpath or os.path.abspath are different ways of transforming paths so they still refer to the same file. It's just worth double-checking to make sure that we're not doing that kind of thing when transforming the path (or that the original path is already normalized in the same way, which it probably is).

I suggested if dest != old_dest so that (normalization aside) this message only gets printed when there is an actual change.

For testing, all I mean is running this on a few files—perhaps in the same cases that presumably motivated you to add this log message—and make sure that the message shows up when it's supposed to (and doesn't appear when it isn't).

beets/library.py Outdated Show resolved Hide resolved
@JOJ0
Copy link
Member

JOJ0 commented Nov 16, 2023

Is there something to do here still @fleur? Was the if dest != old_dest suggestion sorted out (#4924 (comment))? Or new ideas? I think this is a candidate for merging soon. Please tell us when you think it is ready for a final review :-) HTH

Copy link

stale bot commented Mar 17, 2024

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants