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

only copy theme resources when they actually change #990

Merged
merged 3 commits into from
Sep 8, 2018
Merged

Conversation

bridiver
Copy link
Contributor

@bridiver bridiver commented Sep 6, 2018

fix #989

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Verified that these changes build without errors on
    • Windows
    • macOS
    • Linux
  • Verified that these changes pass automated tests (npm test brave_unit_tests && npm test brave_browser_tests) on
    • Windows
    • macOS
    • Linux
  • Ran git rebase master (if needed).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Requested a security/privacy review as needed.

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions.

@bridiver bridiver self-assigned this Sep 6, 2018
// we check for an exact match on the timestamp. We use seconds instead
// of ms because utimesSync doesn't set the times with ms precision
if (!fs.existsSync(destinationFile) ||
Math.floor(new Date(fs.statSync(sourceFile).mtimeMs).getTime() / 1000) !=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally we'd use a file hash here, but that might take a while

lib/util.js Outdated

if (process.platform === 'darwin') {
// Copy proper mac app icon for channel to chrome/app/theme/mac/app.icns.
// Each channel's app icons are stored in brave/app/theme/$channel/app.icns.
// With this copying, we don't need to modify chrome/BUILD.gn for this.
fs.copySync(path.join(braveAppDir, 'theme', 'brave', 'mac', config.channel, 'app.icns'),
path.join(chromeAppDir, 'theme', 'brave', 'mac', 'app.icns'))
fileMap[path.join(braveAppDir, 'theme', 'brave', 'mac', config.channel, 'app.icns')] =
Copy link
Member

@simonhong simonhong Sep 7, 2018

Choose a reason for hiding this comment

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

I think these two files (icon and BRANDING) should be handled differently.
When different channel is built from previous, these two files should be copied.
This kinds of file could be candidates for file hash check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it should still work because I'm checking the actual timestamp and not just checking to see which one is newer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it could still be a problem if you switch channels back and forth because you'll end up with the same timestamp for all of them at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change to hash

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

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

LGTM! Great to remove no-branding-update option!! 👍

@bbondy bbondy merged commit c2c4e76 into master Sep 8, 2018
bbondy added a commit that referenced this pull request Sep 8, 2018
only copy theme resources when they actually change
@bbondy
Copy link
Member

bbondy commented Sep 8, 2018

0.55.x ac51cfb

@bbondy bbondy added the 0.55.x label Sep 8, 2018
@bbondy
Copy link
Member

bbondy commented Sep 8, 2018

Needed a small follow up here:
0.55.x 05a6963
master b915275

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.

Theme resources are always copied which triggers unnecessary rebuilds
3 participants