From bcedc6b7b5ac87a86b6095dc4f1e032fb54544d0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 20 Jun 2014 04:00:25 -0400 Subject: [PATCH] feature(flop) create: only dir --- lib/server/flop.js | 19 +------------------ lib/server/rest/fs/get.js | 6 ++++-- lib/server/rest/fs/put.js | 16 ++++++++++------ 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/server/flop.js b/lib/server/flop.js index d4a086ba..0e9d9e4a 100644 --- a/lib/server/flop.js +++ b/lib/server/flop.js @@ -22,23 +22,7 @@ exports.create = function(path, type, callback) { Util.checkArgs(arguments, ['path', 'callback']); - if (!callback) { - callback = type; - type = 'file'; - } - - if (!type) - type = 'file'; - - switch(type) { - case 'file': - fs.writeFile(path, '', callback); - break; - - case 'dir': - mkdir(path, callback); - break; - } + mkdir(path, callback); }; exports.read = function(path, type, callback) { @@ -136,7 +120,6 @@ switch(type) { default: - console.log(ncp); (ncp || pipe.create)(from, to, callback); break; diff --git a/lib/server/rest/fs/get.js b/lib/server/rest/fs/get.js index 1652fcf9..c695418d 100644 --- a/lib/server/rest/fs/get.js +++ b/lib/server/rest/fs/get.js @@ -35,7 +35,7 @@ if (!hash) { error = 'hash: not suported, try update node'; - callback(new Error(error)); + func(new Error(error)); } else pipe.create(name, hash, function (error) { var hex; @@ -43,7 +43,9 @@ if (!error) hex = hash.get(); - callback(error, hex); + console.log(hex); + + func(error, hex); }); break; diff --git a/lib/server/rest/fs/put.js b/lib/server/rest/fs/put.js index 3318fc1f..6da7babd 100644 --- a/lib/server/rest/fs/put.js +++ b/lib/server/rest/fs/put.js @@ -2,15 +2,15 @@ '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, - DIR = '../../', - flop = require(DIR + 'flop'); + DIR = '../../../', + DIR_SERVER = DIR + 'server/', + flop = require(DIR_SERVER + 'flop'), + Util = require(DIR + 'util'), + pipe = require(DIR_SERVER + 'pipe'); exports.onPut = onPut; @@ -31,6 +31,10 @@ break; + case 'file': + fs.writeFile(name, '', callback); + break; + default: flop.write(name, readStream, 'unzip', function(error) { var msg; @@ -43,7 +47,7 @@ break; case 'patch': - dir.getSize(name, function(error, size) { + flop.read(name, 'size', function(error, size) { var MAX_SIZE = CloudFunc.MAX_FILE_SIZE; if (!error)