зеркало из https://github.com/mozilla/betachannel.git
Bug fix, use App DynamoDb info
This commit is contained in:
Родитель
c4d687adcc
Коммит
cbc35c812a
|
@ -23,8 +23,6 @@ exports.App.prototype.makeAppId = appBase.makeAppId;
|
|||
|
||||
exports.App.prototype.deleteApp = function(cb) {
|
||||
var theApp = this;
|
||||
// Uses versionList instead of this.versionList to avoid
|
||||
// leaving data, even if we have bugs in synchronizing our list
|
||||
versionList(this, function(err, versions) {
|
||||
async.each(versions, function(version, eachCB) {
|
||||
loadByVersion(theApp, version[0], function(err, aVersion) {
|
||||
|
@ -32,7 +30,7 @@ exports.App.prototype.deleteApp = function(cb) {
|
|||
console.log('Error while enumerating known versions');
|
||||
console.log(err.stack || err);
|
||||
return eachCB(err);
|
||||
} else {
|
||||
} else if ( !! aVersion) {
|
||||
aVersion.deleteVersion(function(err) {
|
||||
if (err) {
|
||||
console.log('Error while deleting one of the versions');
|
||||
|
@ -41,10 +39,26 @@ exports.App.prototype.deleteApp = function(cb) {
|
|||
}
|
||||
eachCB();
|
||||
});
|
||||
} else {
|
||||
eachCB();
|
||||
}
|
||||
});
|
||||
}, function(err) {
|
||||
cb(err);
|
||||
var dynamoDB = new AWS.DynamoDB();
|
||||
var params = {
|
||||
TableName: DB.APPS,
|
||||
Key: {
|
||||
appId: {
|
||||
S: theApp.appId
|
||||
},
|
||||
},
|
||||
ReturnConsumedCapacity: 'NONE',
|
||||
ReturnItemCollectionMetrics: 'NONE',
|
||||
ReturnValues: 'NONE'
|
||||
};
|
||||
dynamoDB.deleteItem(params, function(err, data) {
|
||||
cb(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -171,40 +171,11 @@ exports.loadByVersion = function(app, versionId, cb) {
|
|||
};
|
||||
|
||||
exports.latestVersionForApp = function(app, cb) {
|
||||
var dynamoDB = new AWS.DynamoDB();
|
||||
var params = {
|
||||
TableName: DB.VERSIONS,
|
||||
IndexName: DB.VERSIONS_BY_APP_NAME,
|
||||
AttributesToGet: ['versionId', 'appId', 'manifest', 'createdAt'],
|
||||
Select: 'SPECIFIC_ATTRIBUTES',
|
||||
KeyConditions: {
|
||||
appId: {
|
||||
ComparisonOperator: 'EQ',
|
||||
AttributeValueList: [{
|
||||
S: app.code
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
dynamoDB.query(params, function(err, data) {
|
||||
if (err) return cb(err);
|
||||
|
||||
if (data.Count > 0) {
|
||||
|
||||
// TODO this isn't very efficient
|
||||
var latest = 0;
|
||||
for (var i = 1; i < data.Count; i++) {
|
||||
var latestTime = parseInt(data.Items[latest].createdAt, 10);
|
||||
var curTime = parseInt(data.Items[i].createdAt, 10);
|
||||
if (latestTime < curTime) {
|
||||
latest = i;
|
||||
}
|
||||
}
|
||||
return exports.loadByVersion(app, data.Items[latest].versionId.S, cb);
|
||||
} else {
|
||||
cb(err, null);
|
||||
}
|
||||
});
|
||||
if (app && app.latestVersion) {
|
||||
return exports.loadByVersion(app, app.latestVersion, cb);
|
||||
} else {
|
||||
cb(err, null);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: version number - from system or from the manifest.version?
|
||||
|
@ -212,43 +183,14 @@ exports.latestVersionForApp = function(app, cb) {
|
|||
// TODO make versionId nicer than UUID?
|
||||
// or
|
||||
// Support short codes?
|
||||
/**
|
||||
* This method if for getting all of the Version documents from
|
||||
* DynamoDB for deletion... use App.versionList for most
|
||||
* purposes
|
||||
*/
|
||||
exports.versionList = function(app, cb) {
|
||||
var dynamoDB = new AWS.DynamoDB();
|
||||
var params = {
|
||||
TableName: DB.VERSIONS,
|
||||
IndexName: DB.VERSIONS_BY_APP_NAME,
|
||||
AttributesToGet: ['versionId', 'appId', 'manifest', 'createdAt'],
|
||||
Select: 'SPECIFIC_ATTRIBUTES',
|
||||
KeyConditions: {
|
||||
appId: {
|
||||
ComparisonOperator: 'EQ',
|
||||
AttributeValueList: [{
|
||||
S: app.appId
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
dynamoDB.query(params, function(err, data) {
|
||||
if (!err && data.Count > 0) {
|
||||
var versionList = [];
|
||||
for (var i = 0; i < data.Count; i++) {
|
||||
try {
|
||||
var version = JSON.parse(data.Items[i].manifest.S).version;
|
||||
versionList.push([data.Items[i].versionId.S, version]);
|
||||
} catch (e) {
|
||||
console.log('Trouble parsing manifest on ', data.Items[i].versionId.S);
|
||||
}
|
||||
}
|
||||
cb(err, versionList);
|
||||
} else {
|
||||
cb(err, []);
|
||||
}
|
||||
});
|
||||
var versionList = [];
|
||||
for (var i = 0; i < app.versionList.versions.length; i++) {
|
||||
var ver = app.versionList.versions[i];
|
||||
versionList.push([ver.id, ver.version]);
|
||||
}
|
||||
|
||||
cb(null, versionList);
|
||||
};
|
||||
|
||||
function populate(aVersion, manifest, dynData) {
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
<h2>{{version.manifest.name}}</h2>
|
||||
<h3>Install Link</h3>
|
||||
<div class="install-link">
|
||||
<a href="{{version.installUrl}}">Install Current Version</a> <a href="" class="share">Share</a>
|
||||
<a href="{{version.installUrl}}">Install Current</a> Version {{version.version}} <a href="" class="share">Share</a>
|
||||
</div>
|
||||
<h3>Versions</h3>
|
||||
<h3>Version History</h3>
|
||||
<ol class="versions">
|
||||
{% for ver in versions %}
|
||||
<li id='version-{{ver[0]}}'><a href="/app/v/{{ ver[0] | string | urlencode }}/install/{{ app.code | urlencode }}">Version {{ ver[1] }}</a>
|
||||
|
|
Загрузка…
Ссылка в новой задаче