Skip to content

Commit

Permalink
Don't overwrite scripts with dependencies that have the same name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ventero committed Apr 3, 2014
1 parent a0d93c5 commit dc19a22
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions modules/remoteScript.js
Expand Up @@ -317,10 +317,26 @@ RemoteScript.prototype.install = function(aOldScript, aOnlyDependencies) {

if (aOnlyDependencies) {
// Just move the dependencies in.
var enumerator = this._tempDir.directoryEntries;
while (enumerator.hasMoreElements()) {
var file = enumerator.getNext().QueryInterface(Ci.nsIFile);
file.moveTo(this.script.baseDirFile, null);
for (var i = 0, dep = null; dep = this._dependencies[i]; i++) {
// Make sure this is actually a file, not a data URI.
if (!dep._filename) continue;

// Grab a unique file name to ensure we don't overwrite the script in case
// it has the same name as one of the dependencies. See #1906.
var target = GM_util.getTempFile(this.script.baseDirFile, dep.filename);

var file = this._tempDir.clone();
file.append(dep.filename);
file.moveTo(this.script.baseDirFile, target.leafName);

dep.setFilename(target);
}

// Only delete the temporary directory if it's empty.
try {
this._tempDir.remove(false);
} catch (e) {
// silently ignore
}
} else {
// Completely install the new script.
Expand Down

0 comments on commit dc19a22

Please sign in to comment.