mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Avoid unnecessary files.{rm_recursive,symlink} in symlinkWithOverwrite.
When we copy node_modules directories during rebuilds, we try to create symlinks instead of doing a full recursive copy. Very often, however, the symlinks already exist, and they point to the right location already, so we can avoid recreating them for even better performance. Another optimization identified by using the qualia:profile package created by @veered: https://atmospherejs.com/qualia/profile
This commit is contained in:
@@ -533,6 +533,11 @@ export function symlinkWithOverwrite(source, target) {
|
||||
files.symlink(source, target);
|
||||
} catch (e) {
|
||||
if (e.code === "EEXIST") {
|
||||
if (files.readlink(target) === source) {
|
||||
// If the target already points to the desired source, we don't
|
||||
// need to do anything.
|
||||
return;
|
||||
}
|
||||
// overwrite existing link, file, or directory
|
||||
files.rm_recursive(target);
|
||||
files.symlink(source, target);
|
||||
|
||||
Reference in New Issue
Block a user