Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Windows: Avoid collision of entry IDs for WiX (#141)
Browse files Browse the repository at this point in the history
Entry IDs would be created using the filename component of a path
only, so if the same filename occurred in different paths, the
same ID would result, and cause WiX to fail.

Now the ID is created using a file's absolute path, which is
guaranteed to be unique.

BUG=APPTOOLS-43
  • Loading branch information
r0b5t4 committed May 24, 2016
1 parent a0a1703 commit 9481b56
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions windows/lib/WixSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function WixSDK(rootPath, manifest, output) {
this._rootPath = rootPath;
this._manifest = manifest;
this._output = output;

this._existing_ids = {};
}

/**
Expand Down Expand Up @@ -152,26 +154,28 @@ function(app_path, xwalk_path, meta_data, callback) {

var file_ids = [];

function MakeIdFromPath(path) {
var shasum = crypto.createHash('sha1');
existing_ids = {};
var MakeIdFromPath = function(path) {

if (this._existing_ids[path]) {
return this._existing_ids[path];
}

var shasum = crypto.createHash('sha1');
var id = '_' + shasum.update(path).digest('hex');
while (existing_ids.hasOwnProperty(id) && existing_ids[id] != path)
id = '_' + shasum.update(id).digest('hex');

existing_ids[id] = path;
this._existing_ids[path] = id;

return id;
}

}.bind(this);

// To be used for cmd line arguments.
function InQuotes(arg) {
return "\"" + arg + "\"";
}

function AddFileComponent(node, base_path, relative_path) {
var file_id = MakeIdFromPath(relative_path);
var file_id = MakeIdFromPath(path.join(base_path, relative_path));
file_ids.push(file_id);
var component = node.ele('Component', { Id: file_id, Guid: uuid.v1() });
var source_path = (base_path.length === 0) ? relative_path
Expand Down

0 comments on commit 9481b56

Please sign in to comment.