Merge pull request #311 from mozilla/expiredDownloadPage

expired ids should reject instead of returning null
This commit is contained in:
Danny Coates 2017-07-25 13:10:46 -07:00 committed by GitHub
commit 65c24990cd
4 changed files with 21 additions and 43 deletions

View File

@ -19,9 +19,7 @@ class FileReceiver extends EventEmitter {
xhr.onload = function(event) { xhr.onload = function(event) {
if (xhr.status === 404) { if (xhr.status === 404) {
reject( reject(new Error('notfound'));
new Error('notfound')
);
return; return;
} }

View File

@ -135,7 +135,7 @@ $(document).ready(function() {
event.preventDefault(); event.preventDefault();
// don't allow upload if not on upload page // don't allow upload if not on upload page
if ($('#page-one').attr('hidden')){ if ($('#page-one').attr('hidden')) {
return; return;
} }
@ -472,7 +472,7 @@ $(document).ready(function() {
const $popupNvmSpan = $('<span>', { class: 'popup-no' }); const $popupNvmSpan = $('<span>', { class: 'popup-no' });
$popupNvmSpan.attr('data-l10n-id', 'deletePopupCancel'); $popupNvmSpan.attr('data-l10n-id', 'deletePopupCancel');
$popupText.html([$popupMessage, $popupDelSpan, $popupNvmSpan]); $popupText.html([$popupMessage, $popupDelSpan, $popupNvmSpan]);
// add data cells to table row // add data cells to table row
row.appendChild(name); row.appendChild(name);

View File

@ -47,10 +47,7 @@ app.use(
'https://sentry.prod.mozaws.net', 'https://sentry.prod.mozaws.net',
'https://www.google-analytics.com' 'https://www.google-analytics.com'
], ],
imgSrc: [ imgSrc: ["'self'", 'https://www.google-analytics.com'],
"'self'",
'https://www.google-analytics.com'
],
scriptSrc: ["'self'"], scriptSrc: ["'self'"],
styleSrc: ["'self'", 'https://code.cdn.mozilla.net'], styleSrc: ["'self'", 'https://code.cdn.mozilla.net'],
fontSrc: ["'self'", 'https://code.cdn.mozilla.net'], fontSrc: ["'self'", 'https://code.cdn.mozilla.net'],
@ -116,10 +113,10 @@ app.get('/download/:id', (req, res) => {
return; return;
} }
storage.filename(id).then(filename => { storage
storage .filename(id)
.length(id) .then(filename => {
.then(contentLength => { return storage.length(id).then(contentLength => {
storage.ttl(id).then(timeToExpiry => { storage.ttl(id).then(timeToExpiry => {
res.render('download', { res.render('download', {
filename: decodeURIComponent(filename), filename: decodeURIComponent(filename),
@ -128,11 +125,11 @@ app.get('/download/:id', (req, res) => {
timeToExpiry: timeToExpiry timeToExpiry: timeToExpiry
}); });
}); });
})
.catch(() => {
res.status(404).render('notfound');
}); });
}); })
.catch(() => {
res.status(404).render('notfound');
});
}); });
app.get('/assets/download/:id', (req, res) => { app.get('/assets/download/:id', (req, res) => {

View File

@ -27,7 +27,6 @@ if (conf.s3_bucket) {
length: awsLength, length: awsLength,
get: awsGet, get: awsGet,
set: awsSet, set: awsSet,
aad: aad,
setField: setField, setField: setField,
delete: awsDelete, delete: awsDelete,
forceDelete: awsForceDelete, forceDelete: awsForceDelete,
@ -44,7 +43,6 @@ if (conf.s3_bucket) {
length: localLength, length: localLength,
get: localGet, get: localGet,
set: localSet, set: localSet,
aad: aad,
setField: setField, setField: setField,
delete: localDelete, delete: localDelete,
forceDelete: localForceDelete, forceDelete: localForceDelete,
@ -66,11 +64,10 @@ function quit() {
function metadata(id) { function metadata(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
redis_client.hgetall(id, (err, reply) => { redis_client.hgetall(id, (err, reply) => {
if (!err) { if (err || !reply) {
resolve(reply); return reject(err);
} else {
reject(err);
} }
resolve(reply);
}); });
}); });
} }
@ -78,11 +75,10 @@ function metadata(id) {
function ttl(id) { function ttl(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
redis_client.ttl(id, (err, reply) => { redis_client.ttl(id, (err, reply) => {
if (!err) { if (err || !reply) {
resolve(reply * 1000); return reject(err);
} else {
reject(err);
} }
resolve(reply * 1000);
}); });
}); });
} }
@ -90,11 +86,10 @@ function ttl(id) {
function filename(id) { function filename(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
redis_client.hget(id, 'filename', (err, reply) => { redis_client.hget(id, 'filename', (err, reply) => {
if (!err) { if (err || !reply) {
resolve(reply); return reject();
} else {
reject(err);
} }
resolve(reply);
}); });
}); });
} }
@ -115,18 +110,6 @@ function setField(id, key, value) {
redis_client.hset(id, key, value); redis_client.hset(id, key, value);
} }
function aad(id) {
return new Promise((resolve, reject) => {
redis_client.hget(id, 'aad', (err, reply) => {
if (!err) {
resolve(reply);
} else {
reject();
}
});
});
}
function localLength(id) { function localLength(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {