diff --git a/lib/client/edit.js b/lib/client/edit.js index aa1ad37f..498bc94f 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -171,23 +171,29 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; lValue = Ace.getValue(); CloudCmd.getConfig(function(config) { - var isDiff = config.diff; + var isDiff = config.diff; Util.ifExec(!isDiff, function(patch) { var query, + MAX_SIZE = CloudFunc.MAX_FILE_SIZE, + + length = lValue.length, + + isLength = length > MAX_SIZE, isAllowed = DOM.Storage.isAllowed(); Value = lValue; - Util.ifExec(!isAllowed, function() { + Util.ifExec(isLength && !isAllowed, function() { DOM.RESTful.save(lPath, lValue, onSave, query); }, function(callback) { DOM.checkStorageHash(lPath, function(error, equal) { var isString = Util.isString(patch), - lessLength = patch.length < lValue.length; + patchLength = patch.length, + lessLength = patchLength < length; if (!error) { - if (equal && isString && patch.length && lessLength) { + if (equal && isString && patchLength && lessLength) { lValue = patch; query = '?patch'; } diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index c749a047..742220ed 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -48,6 +48,8 @@ var Util; this.CHANNEL_CONSOLE = 'console-data'; this.CHANNEL_TERMINAL = 'terminal-data'; this.CHANNEL_TERMINAL_RESIZE= 'terminal-resize'; + this.MAX_FILE_SIZE = 500 * 1024; + this.addListener = function(name, func, allListeners, socket) { var listeners, obj; diff --git a/lib/server/rest/fs/put.js b/lib/server/rest/fs/put.js index e5fe27f4..86a34dfb 100644 --- a/lib/server/rest/fs/put.js +++ b/lib/server/rest/fs/put.js @@ -48,7 +48,7 @@ case 'patch': dir.getSize(name, function(error, size) { - var MAX_SIZE = 100 * 1024; + var MAX_SIZE = CloudFunc.MAX_FILE_SIZE; if (!error) if (size < MAX_SIZE) @@ -56,7 +56,7 @@ patchFile(patch); }); else - error = 'File is to big.'; + error = 'File is to big. Disable diff.'; if (error) func(error);