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

symlink (rather than copy) files that don't need to be compiled #150

Closed
notslang opened this issue Jun 7, 2013 · 14 comments
Closed

symlink (rather than copy) files that don't need to be compiled #150

notslang opened this issue Jun 7, 2013 · 14 comments
Milestone

Comments

@notslang
Copy link
Collaborator

notslang commented Jun 7, 2013

Right now, we copy all the files over from assets to the public folder. As an optimization, couldn't we just symlink any files (or entire directories of files) that don't need to be compiled?

This would be really great because creating a symlink from the public folder to a file in the assets folder requires far less disk I/O than copying it over. Also, symlinks are nearly invisible to most applications.

I don't think this would work on windows (because it does something stupid with .lnk files to simulate symlinks), but I doubt there are many developers using windows anyway, so it should be fine.

@jescalan
Copy link
Owner

jescalan commented Jun 7, 2013

Hahah I love the last paragraph. This is a really interesting idea though, I'll have to think about it. Breaking windows is somewhat of a concern, but it's true that hardly anyone using roots is on windows.

@samccone
Copy link
Collaborator

samccone commented Jun 7, 2013

maybe an option? or we can detect windows? process.arch i think

@jescalan
Copy link
Owner

jescalan commented Jun 7, 2013

http://nodejs.org/api/fs.html#fs_fs_symlink_srcpath_dstpath_type_callback - kind of funny that node's symlink util only works on windows O_o

@samccone
Copy link
Collaborator

samccone commented Jun 7, 2013

👊

@jescalan
Copy link
Owner

jescalan commented Jun 7, 2013

does anyone know of a linux/mac node symlink library, or do we have to resort to exec?

@notslang
Copy link
Collaborator Author

notslang commented Jun 7, 2013

The type option of fs.symlink is only used on windows, the function works on all platforms, it just ignores the type option on mac/linux.

Also, I'm not saying that it would break windows, it would just not be as optimized on windows since it doesn't know how to make symlinks properly.

@zspecza
Copy link
Contributor

zspecza commented Jun 8, 2013

I develop on Windows - a Mac is far too expensive, and data costs are high in my country too, so simply downloading a linux flavour isn't an option. Never assume that not many people develop on Windows. Not many people are blind, but we still work our butts off making sites accessible to them, no? Same thing here. 😄

I understand symlink is the preferred option, but if it isn't at all possible - then why not just cache files after compiling them and compare file's modified dates to the ones in the cache? It's a strategy that would work on all platforms.

@notslang
Copy link
Collaborator Author

notslang commented Jun 8, 2013

You can't get linux?! Oh god... that's so sad! Usually the ISOs are only 700-800M, but if that's too much I'll gladly send you a Ubuntu DVD. What's your postal address and CPU architecture?

As for the linux/mac only optimization, roots would still be "accessible" to windows users, it just would be at the same speed that it is right now because the platform can't do proper symlinks. And I think that we're also trying to do the caching idea, but we need #149 to be implemented first... But both of those optimizations can work together, so one is not a replacement for the other.

@jescalan
Copy link
Owner

So I assume you meant that this would only happen on watch since assets would definitely have to be copied on compile -- no?

@notslang
Copy link
Collaborator Author

exactly

On Tue, Jun 11, 2013 at 4:41 PM, Jeff Escalante [email protected]:

So I assume you meant that this would only happen on watch since assets
would definitely have to be copied on compile -- no?


Reply to this email directly or view it on GitHubhttps://github.com//issues/150#issuecomment-19294377
.

@L8D
Copy link
Contributor

L8D commented Jun 11, 2013

Helpful reminder: if a user is using the GNU(but no busybox, etc.) rm utility recursively, it will also remove the originally linked files. For example, if we have a photo from assets/img that gets linked to public/img and a user decides to rm -rf public then the original image inside assets/img also gets deleted.

This being said, I think we need to have an option to do the dynamic linking, and/or have a way to specify a file to be linked(instead of being compiled) during a compile.

Nevermind, I was thinking this would occur during a roots compile and link to the public folder...I wasn't thinking correctly.

@cspotcode
Copy link

Another Windows user here. Windows is the sensible choice at my job. Although they technically allow us to request Macs, it's not worth the effort. Plus, I build my own personal desktops and play a lot of games that are Windows-only, and it makes sense to use Windows 100% so I don't have to context switch or maintain multiple OS installations.

Windows required you to be Administrator to create symlinks, meaning roots watch fails unless I run it as admin. (which is super-annoying) Windows does allow creating junction points as regular non-admin users, but those are only for directories, not files.

@zspecza
Copy link
Contributor

zspecza commented Jul 5, 2013

Roots watch requires you to be running as Admin? That's strange - I haven't needed admin privileges for Roots since I typed this command: $ npm install -g roots

@cspotcode
Copy link

Are you using a version of roots that symlinks files in development mode, or are you using an older version?

For me, in Windows 7 with an NTFS filesystem, Node throws an error when roots attempts to create a symlink. In general, when I want to create a symlink on Windows, I always have to do it from a command prompt that's running as admin.

According to the NTFS Wikipedia article this restriction is a default security setting and can be changed with the Local Security Policy management console.

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

No branches or pull requests

6 participants