Skip to content

Commit

Permalink
Early exit from copy-file(s).js
Browse files Browse the repository at this point in the history
Now that we have copy functions that do not create hardlinks in gen, it
shouldn't be necessary to remove the target file before writing. This CL
removes the unlinking and early exits.

Change-Id: I8e099224479458d446977f930065b4c54a3d0ac6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2334972
Commit-Queue: Paul Lewis <[email protected]>
Auto-Submit: Paul Lewis <[email protected]>
Reviewed-by: Jack Franklin <[email protected]>
  • Loading branch information
paullewis authored and Commit Bot committed Aug 11, 2020
1 parent 2924ca1 commit 7e3e7bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions scripts/build/ninja/copy-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ const destPath = path.join(process.cwd(), dest);
// If there's a file there from a previous build, unlink it first. This
// is because the file in that location might be a hardlinked file, and
// overwriting it doesn't change the fact that it's hardlinked.
const srcContents = fs.readFileSync(srcPath);
if (fs.existsSync(destPath)) {
fs.unlinkSync(destPath);
// Check contents, return early if match
const destContents = fs.readFileSync(destPath);
if (srcContents.equals(destContents)) {
return;
}
}

// Force a write to the target filesystem, since by default the ninja
// toolchain will create a hardlink, which in turn reflects changes in
// gen and resources/inspector back to //front_end.
fs.writeFileSync(destPath, fs.readFileSync(srcPath));
fs.writeFileSync(destPath, srcContents);
9 changes: 7 additions & 2 deletions scripts/build/ninja/copy-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ for (const file of files.split(',')) {
// If there's a file there from a previous build, unlink it first. This
// is because the file in that location might be a hardlinked file, and
// overwriting it doesn't change the fact that it's hardlinked.
const srcContents = fs.readFileSync(srcPath);
if (fs.existsSync(destPath)) {
fs.unlinkSync(destPath);
// Check contents, return early if match
const destContents = fs.readFileSync(destPath);
if (srcContents.equals(destContents)) {
return;
}
}

// Force a write to the target filesystem, since by default the ninja
// toolchain will create a hardlink, which in turn reflects changes in
// gen and resources/inspector back to //front_end.
fs.writeFileSync(destPath, fs.readFileSync(srcPath));
fs.writeFileSync(destPath, srcContents);
}

0 comments on commit 7e3e7bb

Please sign in to comment.