Skip to content

Commit

Permalink
Don't let options.hash override File#hash() salting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Newman committed Nov 8, 2016
1 parent 08016d2 commit 9321151
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tools/isobuild/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ class File {
this.assets = null;

this._contents = options.data || null; // contents, if known, as a Buffer
this._hash = options.hash || null; // hash, if known, as a hex string
this._hashOfContents = options.hash || null;
this._hash = null;
}

toString() {
Expand All @@ -567,11 +568,16 @@ class File {

hash() {
if (! this._hash) {
if (! this._hashOfContents) {
this._hashOfContents = watch.sha1(this.contents());
}

this._hash = watch.sha1(
String(File._salt()),
this.contents(),
this._hashOfContents,
);
}

return this._hash;
}

Expand All @@ -595,7 +601,7 @@ class File {
}
this._contents = b;
// Un-cache hash.
this._hash = null;
this._hashOfContents = this._hash = null;
}

size() {
Expand Down

0 comments on commit 9321151

Please sign in to comment.