Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,25 @@ function lookupSandbox(spec, callback) {
return;
}

callback(new Error('Found ' + filtered.length + ' matching sandboxes.'));
// multiple sandboxes should be the very exception and in those cases the most recently created
// sandbox should be addressed with the requested operation. in all other cases the operation should
// be skipped and error messages returned.
filtered = filtered.sort( function sortFilteredSandboxesDesc(sb1, sb2) {
return sb1.createdAt.localeCompare(sb2.createdAt) * -1;
});

var sandboxIndex = 1;
filtered.forEach( function(sbxInfo) {
if (sandboxIndex === 1) {
console.warn('More than one sandbox found. Executing the operation only for '
+ 'the sandbox that has been created on ' + sbxInfo.createdAt);
callback(undefined , sbxInfo);
} else {
callback(new Error('Ambigious sandbox ID. Skipping operation for the sandbox that has '
+ 'been created on ' + sbxInfo.createdAt));
}
sandboxIndex++;
});
});
}

Expand Down