From 02dbe9e4583e5383e5ffa5ee26d8304dab5fc8a4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 18 Jan 2018 12:19:58 +0100 Subject: [PATCH] enforce maxUploadSize --- customize.dist/translations/messages.js | 2 ++ rpc.js | 1 + www/common/sframe-common-file.js | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index f554de85b..cd58bc9fb 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -571,7 +571,9 @@ define(function () { out.upload_uploadPending = "You already have an upload in progress. Cancel it and upload your new file?"; out.upload_success = "Your file ({0}) has been successfully uploaded and added to your drive."; out.upload_notEnoughSpace = "There is not enough space for this file in your CryptDrive."; + out.upload_notEnoughSpaceBrief = "Not enough space"; out.upload_tooLarge = "This file exceeds the maximum upload size."; + out.upload_tooLargeBrief = 'File too large'; out.upload_choose = "Choose a file"; out.upload_pending = "Pending"; out.upload_cancelled = "Cancelled"; diff --git a/rpc.js b/rpc.js index af03b8c06..87f01a057 100644 --- a/rpc.js +++ b/rpc.js @@ -935,6 +935,7 @@ var upload_status = function (Env, publicKey, filesize, cb) { if (typeof(filesize) !== 'number' && filesize >= 0) { return void cb('E_INVALID_SIZE'); } + if (filesize >= Env.maxUploadSize) { return cb('TOO_LARGE'); } // validate that the provided path is not junk var filePath = makeFilePath(paths.staging, publicKey); if (!filePath) { return void cb('E_INVALID_PATH'); } diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index bc0dd3374..ab3111ff0 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -131,11 +131,11 @@ define([ queue.inProgress = false; queue.next(); if (e === 'TOO_LARGE') { - // TODO update table to say too big? + $pv.text(Messages.upload_tooLargeBrief); return void UI.alert(Messages.upload_tooLarge); } if (e === 'NOT_ENOUGH_SPACE') { - // TODO update table to say not enough space? + $pv.text(Messages.upload_notEnoughSpaceBrief); return void UI.alert(Messages.upload_notEnoughSpace); } console.error(e);