mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(flop) mv hash to get
This commit is contained in:
parent
9a54951652
commit
4df9fdaa2d
2 changed files with 19 additions and 22 deletions
|
|
@ -13,7 +13,6 @@
|
|||
dir = require(DIR + 'dir'),
|
||||
commander = require(DIR + 'commander'),
|
||||
time = require(DIR + 'time'),
|
||||
Hash = require(DIR + 'hash'),
|
||||
pipe = require(DIR + 'pipe'),
|
||||
|
||||
ncp = tryRequire('ncp'),
|
||||
|
|
@ -43,8 +42,6 @@
|
|||
};
|
||||
|
||||
exports.read = function(path, type, callback) {
|
||||
var hash, error;
|
||||
|
||||
Util.checkArgs(arguments, ['path', 'callback']);
|
||||
|
||||
if (!callback)
|
||||
|
|
@ -66,23 +63,6 @@
|
|||
});
|
||||
break;
|
||||
|
||||
case 'hash':
|
||||
hash = Hash.create();
|
||||
|
||||
if (!hash) {
|
||||
error = 'hash: not suported, try update node';
|
||||
callback(new Error(error));
|
||||
} else
|
||||
pipe.create(path, hash, function (error) {
|
||||
var hex;
|
||||
|
||||
if (!error)
|
||||
hex = hash.get();
|
||||
|
||||
callback(error, hex);
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
commander.getDirContent(path, callback);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
var path = require('path'),
|
||||
DIR = path.resolve(__dirname + '/../../../') + '/',
|
||||
DIR_SERVER = DIR + 'server/',
|
||||
pipe = require(DIR_SERVER + 'pipe'),
|
||||
flop = require(DIR_SERVER + 'flop'),
|
||||
Hash = require(DIR_SERVER + 'hash'),
|
||||
CloudFunc = require(DIR + 'cloudfunc'),
|
||||
Util = require(DIR + 'util');
|
||||
|
||||
exports.onGet = onGet;
|
||||
|
||||
function onGet(query, name, callback) {
|
||||
var func = Util.exec.ret(callback);
|
||||
var hash, error,
|
||||
func = Util.exec.ret(callback);
|
||||
|
||||
switch (query) {
|
||||
case 'size':
|
||||
|
|
@ -28,7 +31,21 @@
|
|||
break;
|
||||
|
||||
case 'hash':
|
||||
flop.read(name, 'hash', func);
|
||||
hash = Hash.create();
|
||||
|
||||
if (!hash) {
|
||||
error = 'hash: not suported, try update node';
|
||||
callback(new Error(error));
|
||||
} else
|
||||
pipe.create(name, hash, function (error) {
|
||||
var hex;
|
||||
|
||||
if (!error)
|
||||
hex = hash.get();
|
||||
|
||||
callback(error, hex);
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue