mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(put) pathch: add size check
This commit is contained in:
parent
5a6c0f94e4
commit
37ead0d34a
1 changed files with 20 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue