feature(put) pathch: add size check

This commit is contained in:
coderaiser 2014-03-12 10:52:22 -04:00
parent 5a6c0f94e4
commit 37ead0d34a

View file

@ -1,11 +1,12 @@
(function(){
'use strict';
(function() {
// 'use strict';
var main = global.cloudcmd.main,
Util = main.util,
pipe = main.pipe,
path = require('path'),
fs = require('fs'),
dir = main.srvrequire('dir'),
diff = main.diff,
CloudFunc = main.cloudfunc,
fse = main.require('fs-extra') || {
@ -46,7 +47,22 @@
break;
case 'patch':
pipe.getBody(readStream, function(patch) {
dir.getSize(name, function(error, size) {
var MAX_SIZE = 100 * 1024;
if (!error)
if (size < MAX_SIZE)
pipe.getBody(readStream, function(patch) {
patchFile(patch);
});
else
error = 'File is to big.';
if (error)
func(error);
});
function patchFile(patch) {
fs.readFile(name, 'utf8', read);
function read(error, data) {
@ -76,7 +92,7 @@
func(error, msg);
}
});
}
break;
}
}