mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(size) calcSize: rm error
This commit is contained in:
parent
2343677277
commit
a601d09d4f
1 changed files with 6 additions and 12 deletions
|
|
@ -31,15 +31,8 @@
|
|||
stopOnError = options.stopOnError;
|
||||
}
|
||||
|
||||
function calcSize(error, size) {
|
||||
if (error)
|
||||
if (stopOnError)
|
||||
Util.exec(callback, error);
|
||||
else
|
||||
size = 0;
|
||||
|
||||
total += size;
|
||||
|
||||
function calcSize(size) {
|
||||
total += size || 0;
|
||||
}
|
||||
|
||||
processDir(dir, calcSize, options, function(error) {
|
||||
|
|
@ -50,7 +43,7 @@
|
|||
else
|
||||
result = total;
|
||||
|
||||
Util.exec(callback, error, result);
|
||||
callback(error, result);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -79,14 +72,15 @@
|
|||
if (!wasError || !stopOnError) {
|
||||
if (error) {
|
||||
wasError = true;
|
||||
func(error);
|
||||
callback(error);
|
||||
} else {
|
||||
isDir = stat.isDirectory();
|
||||
|
||||
if (!isDir)
|
||||
func(null, stat.size);
|
||||
func(stat.size);
|
||||
else if (isDir) {
|
||||
++asyncRunning;
|
||||
|
||||
fs.readdir(dir, function(error, files) {
|
||||
onReaddir(error, files, dir);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue