-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
use hard links for fonts instead of symlinks #2258
Conversation
This is intended to address a new issue mentioned in ongoing discussion on #1860 . @jgarber623 please let me know if this fixes your problem. It is working for me now (Mavericks). PS it would have been cleaner to create a new issue. Sometimes people don't notice new discussion on an old PR. |
Fair enough. I'd thought of doing that, but wasn't sure if that was the preferred over commenting. Thanks for clarifying and for making the change! |
@jgarber623 just to be clear, I haven't entered the change yet. This PR passes build tests and works for me. Now I'm going to let it hang out for a few days and gather comment. If possible, it would be good to verify that this approach fixes your issue before proceeding any further. If it is not easy for you to check out this branch and run it, could you try manually creating hard links (instead of Example recipe rm ~/Library/Fonts/SourceCodePro-*.otf
# here, stop and run Font Book to make sure Source Code Pro not present
ln /opt/homebrew-cask/Caskroom/font-source-code-pro/1.017/SourceCodePro_FontsOnly-1.017/OTF/SourceCodePro-*.otf ~/Library/Fonts/
# here, stop and run Font Book to make sure Source Code Pro IS present |
Followed those instructions and can confirm that the fonts show up in Font Book. 👍 |
Not sure I follow: What's the advantage of hard links over copying? |
@Peeja it's a good question. Same as the advantages of symlinks over copying, though a few implementation details are different. First of all, only a single copy of each file is kept on disk, saving space. (Not the world's biggest consideration) Second, the installer can detect if the target holds a link or an ordinary file. If an ordinary file, Because of those similarities, this change has lower impact than switching to copies. However, some users want to install copies. This is not completely out of the question, but requires more changes to the code. It would probably make the most sense as global option which applies to all artifacts. It should still be possible to keep some install/uninstall checks as described above by testing for identical files in the caskroom vs the installation directories. |
How do you detect the difference between a hard link and an ordinary file? A hard link is an ordinary file, no? |
Yes, I am eliding some details for simplicity. A filename is roughly an entry in a directory structure holding a reference to the file contents (contents are somewhere else in the filesystem). So when you first create a file you can think of that as a hard link with only 1 link, but we usually just call it a "file". When you use So, you can use a |
Right, but that doesn't actually let us reuse anything from the symlink method. They're both created with If there's any interest in using non-symlinks for applications as well, I'd suggest going with copies instead of hard links, since you can't hard link an application (because it's a directory). |
per an issue reported by @jgarber623. Recast for compatibility with Homebrew#2300.
I have updated this PR in light of the cleanup in #2300, merge conflict resolved. @Peeja, I think your points are smart and thoughtful, and I am in favor of a user option to enable copying for all artifacts. But I also think that God and Dennis created hardlinks for a reason. Now that code duplication is being removed maybe it will be clearer that this change does indeed reuse most of the symlink method. See the class PS You can create directory hardlinks on some systems. Recent OS X + HFS+ is one example. They are used for the implementation of Time Machine. We were discussing possible uses recently in #2264. |
Oh. Well. In that case, neat! |
Okay after discussing with @rolandwalker I think this is a reasonable move to make. We can always fall back to a |
use hard links for fonts instead of symlinks
per an issue reported by @jgarber623