Skip to content

Commit

Permalink
Some more optimizing (#1235)
Browse files Browse the repository at this point in the history
* Was planning on doing something different until I hit a snag with the dep... so clean it up to current until that is resolved... at least code base will be there if needed later on from the noise.

Applies to #438

Auto-merge
  • Loading branch information
Martii authored Nov 5, 2017
1 parent 834d982 commit 0a31c13
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1157,13 +1157,9 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
var userscriptKey = null;
var openuserjsKeyset = null;
var thisKeyComponents = null;
var thisSPDX = null;
var thatSPDX = null;
var htmlStub = null;
var i = null;
var j = null;
var hasOSI = null;
var countSPDX = null;
var author = null;
var collaborators = null;
var installName = aUser.name + '/';
Expand Down Expand Up @@ -1301,22 +1297,14 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
}

if (userscriptKeyset) {
hasOSI = false;
thatSPDX = userscriptKeyset[userscriptKeyset.length - 1].split('; ')[0].replace(/\+$/, '');
for (i = 0; thisSPDX = SPDXOSI[i++];) {
if (thisSPDX === thatSPDX) {
hasOSI = true;
}
}

if (!hasOSI) {
if (SPDXOSI.indexOf(thatSPDX) === -1) {
// No valid OSI primary e.g. last key... reject
aCallback(null);
return;
}

countSPDX = 0;
for (i = 0; userscriptKey = userscriptKeyset[i]; i++) {
for (i = 0; userscriptKey = userscriptKeyset[i++];) {
thisKeyComponents = userscriptKey.split('; ');
if (thisKeyComponents.length > 2) {
// Too many parts... reject
Expand All @@ -1334,18 +1322,12 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
}

thatSPDX = thisKeyComponents[0].replace(/\+$/, '');
for (j = 0; thisSPDX = SPDX[j++];) {
if (thisSPDX === thatSPDX) {
countSPDX++;
}
if (SPDX.indexOf(thatSPDX) === -1) {
// Absent SPDX short code... reject
aCallback(null);
return;
}
}

if (countSPDX !== userscriptKeyset.length) {
// Absent SPDX short code... reject
aCallback(null);
return;
}
} else {
// No licensing... reject
// TODO: Enable after a bit of existing Authors getting used to it
Expand Down

0 comments on commit 0a31c13

Please sign in to comment.