mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(files) rm dir
This commit is contained in:
parent
4c561cd628
commit
c10277480a
4 changed files with 63 additions and 21 deletions
|
|
@ -34,18 +34,20 @@
|
|||
express = main.express,
|
||||
expressApp,
|
||||
files = main.files,
|
||||
emptyHandler = function(req, res, next) { Util.exec(next) },
|
||||
|
||||
|
||||
Server, Rest, Route;
|
||||
|
||||
join = join && Util.bind(join, beforeJoin, DIR) || Util.exec.bind(Util);
|
||||
join = join && Util.bind(join, beforeJoin) || emptyHandler;
|
||||
|
||||
/* базовая инициализация */
|
||||
function init(pAppCachProcessing) {
|
||||
var config = main.config;
|
||||
|
||||
/* создаём файл app cache */
|
||||
if (config.appcache && AppCache && config.server )
|
||||
Util.exec( pAppCachProcessing );
|
||||
if (config.appcache && AppCache && config.server)
|
||||
Util.exec( pAppCachProcessing);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -242,32 +244,37 @@
|
|||
}
|
||||
|
||||
function beforeJoin(names, callback) {
|
||||
var i, name, check, minName, dir,
|
||||
var i, name, check, minName,
|
||||
func,
|
||||
funcs = [],
|
||||
dir = DIR,
|
||||
config = main.config,
|
||||
n = names.length;
|
||||
|
||||
if (!config.minify)
|
||||
Util.exec(callback);
|
||||
else {
|
||||
for (i = 0; i < n; i++) {
|
||||
name = Path.join(DIR, names[i]);
|
||||
for (i = 0; i < n; i++) {
|
||||
name = Path.join(dir, names[i]);
|
||||
names[i] = name;
|
||||
|
||||
if (config.minify) {
|
||||
check = checkExtension(name);
|
||||
|
||||
if (check) {
|
||||
minName = Minify.getName(name);
|
||||
|
||||
if (name !== minName) {
|
||||
names[i] = minName;
|
||||
dir = '';
|
||||
names[i] = minName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
funcs.push(Util.bind(minify, name));
|
||||
}
|
||||
|
||||
Util.asyncCall(funcs, callback);
|
||||
}
|
||||
|
||||
func = Util.exec(callback, names);
|
||||
|
||||
Util.ifExec(!config.minify, func, function(callback) {
|
||||
Util.asyncCall(funcs, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function checkExtension(name) {
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
p.write.end();
|
||||
Util.exec(p.callback);
|
||||
} else {
|
||||
name = p.dir + names.shift();
|
||||
name = names.shift();
|
||||
|
||||
pipe.create({
|
||||
from : name,
|
||||
|
|
|
|||
38
lib/server/fstream.js
Normal file
38
lib/server/fstream.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (!global.cloudcmd)
|
||||
return console.log(
|
||||
'# fstream.js' + '\n' +
|
||||
'# -----------' + '\n' +
|
||||
'# Module is part of Cloud Commander,' + '\n' +
|
||||
'# used for work with files.' + '\n' +
|
||||
'# http://cloudcmd.io' + '\n');
|
||||
|
||||
var main = global.cloudcmd.main,
|
||||
fs = main.fs,
|
||||
Util = main.util,
|
||||
fstream = main.require('fstream'),
|
||||
tar = main.require('tar');
|
||||
|
||||
|
||||
exports.pack = packDir;
|
||||
|
||||
function packDir(path, stream) {
|
||||
var dirStream, tarStream, ret;
|
||||
|
||||
if (tar && fstream) {
|
||||
dirStream = fstream.Reader({
|
||||
type: "Directory",
|
||||
path: path
|
||||
});
|
||||
|
||||
tarStream = tar.Pack({});
|
||||
|
||||
ret = dirStream.pipe(tarStream);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
module.exports = join;
|
||||
|
||||
function join(before, dir, req, res, callback) {
|
||||
function join(before, req, res, callback) {
|
||||
var names,
|
||||
readFunc = Util.bind(readPipe, req, res, dir),
|
||||
readFunc = Util.bind(readPipe, req, res),
|
||||
path = main.getPathName(req),
|
||||
isJoin = CloudFunc.isJoinURL(path);
|
||||
|
||||
|
|
@ -20,8 +20,6 @@
|
|||
else {
|
||||
names = CloudFunc.getJoinArray(path);
|
||||
|
||||
readFunc = Util.bind(readFunc, names);
|
||||
|
||||
Util.ifExec(!before, readFunc, function(callback) {
|
||||
before(names, callback);
|
||||
});
|
||||
|
|
@ -30,7 +28,7 @@
|
|||
return isJoin;
|
||||
}
|
||||
|
||||
function readPipe(req, res, dir, names) {
|
||||
function readPipe(req, res, names) {
|
||||
var stream,
|
||||
path = main.getPathName(req),
|
||||
gzip = zlib.createGzip(),
|
||||
|
|
@ -48,7 +46,6 @@
|
|||
|
||||
files.readPipe({
|
||||
names : names,
|
||||
dir : dir,
|
||||
write : stream,
|
||||
callback : function(error) {
|
||||
var errorStr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue