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

test_cleanup: fix moving of same-named files #1256

Merged
merged 1 commit into from
Oct 5, 2024
Merged

Conversation

ZhongRuoyu
Copy link
Member

@ZhongRuoyu ZhongRuoyu commented Oct 5, 2024

Take 2 at #1250; fixes #1250 (comment).

The existing logic for moving files can silently fail when some files to move have a same name. This can be revealed as follows:

$ mv -fv /opt/homebrew/Library/Taps/hashicorp/homebrew-tap /opt/homebrew/Library/Taps/azure/homebrew-bicep /opt/homebrew/Library/Taps/aws/homebrew-tap /private/tmp/d20241005-13189-6pyqe7
/opt/homebrew/Library/Taps/hashicorp/homebrew-tap -> /private/tmp/d20241005-13189-6pyqe7/homebrew-tap
/opt/homebrew/Library/Taps/azure/homebrew-bicep -> /private/tmp/d20241005-13189-6pyqe7/homebrew-bicep
mv: rename /opt/homebrew/Library/Taps/aws/homebrew-tap to /private/tmp/d20241005-13189-6pyqe7/homebrew-tap: Directory not empty

Fix that by creating a temporary directory for each file to move.

The existing logic for moving files can silently fail when some files to
move have a same name. This can be revealed as follows:

    $ mv -fv /opt/homebrew/Library/Taps/hashicorp/homebrew-tap /opt/homebrew/Library/Taps/azure/homebrew-bicep /opt/homebrew/Library/Taps/aws/homebrew-tap /private/tmp/d20241005-13189-6pyqe7
    /opt/homebrew/Library/Taps/hashicorp/homebrew-tap -> /private/tmp/d20241005-13189-6pyqe7/homebrew-tap
    /opt/homebrew/Library/Taps/azure/homebrew-bicep -> /private/tmp/d20241005-13189-6pyqe7/homebrew-bicep
    mv: rename /opt/homebrew/Library/Taps/aws/homebrew-tap to /private/tmp/d20241005-13189-6pyqe7/homebrew-tap: Directory not empty

Fix that by creating a temporary directory for each file to move.
Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Thanks!

@carlocab carlocab merged commit 90abcfa into master Oct 5, 2024
4 checks passed
@carlocab carlocab deleted the mv-same-named-files branch October 5, 2024 18:25
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.

3 participants