|
@@ -99,7 +99,7 @@ function ProgressBar(description, bar_length){
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function downloadFile(path, filename, headcb, progresscb, cb){
|
|
|
|
|
|
|
+function downloadFile_progress(path, filename, headcb, progresscb, cb){
|
|
|
var dest = `o2server/${filename}`;
|
|
var dest = `o2server/${filename}`;
|
|
|
|
|
|
|
|
// fs.exists(dest, function(exists) {
|
|
// fs.exists(dest, function(exists) {
|
|
@@ -144,7 +144,7 @@ function downloadFile(path, filename, headcb, progresscb, cb){
|
|
|
});
|
|
});
|
|
|
request.get(options).pipe(str).pipe(stream);
|
|
request.get(options).pipe(str).pipe(stream);
|
|
|
} else {
|
|
} else {
|
|
|
- gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+response.statusCode);
|
|
|
|
|
|
|
+ gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+res.statusCode);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
req.on('error', (e) => {
|
|
req.on('error', (e) => {
|
|
@@ -154,6 +154,61 @@ function downloadFile(path, filename, headcb, progresscb, cb){
|
|
|
// }
|
|
// }
|
|
|
//});
|
|
//});
|
|
|
}
|
|
}
|
|
|
|
|
+function downloadFile(path, filename, headcb, progresscb, cb){
|
|
|
|
|
+ var dest = `o2server/${filename}`;
|
|
|
|
|
+
|
|
|
|
|
+ // fs.exists(dest, function(exists) {
|
|
|
|
|
+ // if (exists){
|
|
|
|
|
+ // headcb(1);
|
|
|
|
|
+ // progresscb({transferred:1});
|
|
|
|
|
+ // cb();
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ let stream = fs.createWriteStream(dest);
|
|
|
|
|
+ var options = { url:protocol+"://"+downloadHost+path };
|
|
|
|
|
+ var fileHost = downloadHost;
|
|
|
|
|
+ var filePath = path;
|
|
|
|
|
+ stream.on('finish', () => {
|
|
|
|
|
+ //gutil.log("download", ":", gutil.colors.green(filename), " completed!");
|
|
|
|
|
+ cb();
|
|
|
|
|
+ });
|
|
|
|
|
+ stream.on('error', (err) => {
|
|
|
|
|
+ gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), err);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // var req = http.request({
|
|
|
|
|
+ // host:fileHost,
|
|
|
|
|
+ // path:filePath,
|
|
|
|
|
+ // method:'HEAD'
|
|
|
|
|
+ // },function (res){
|
|
|
|
|
+ // if (res.statusCode == 200) {
|
|
|
|
|
+ // res.setEncoding(null);
|
|
|
|
|
+ // var time = 0;
|
|
|
|
|
+ // var l = res.headers['content-length'];
|
|
|
|
|
+ // var str = progress({
|
|
|
|
|
+ // length: l,
|
|
|
|
|
+ // time: 100 /* ms */
|
|
|
|
|
+ // });
|
|
|
|
|
+ // headcb(l);
|
|
|
|
|
+ //
|
|
|
|
|
+ // str.on('progress', function(progress) {
|
|
|
|
|
+ // if (pb){
|
|
|
|
|
+ // progresscb(progress);
|
|
|
|
|
+ // pb.render({ completed: currentLength, total: totalLength, time: time+=100 });
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // });
|
|
|
|
|
+ request.get(options).pipe(stream);
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+res.statusCode);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ // req.on('error', (e) => {
|
|
|
|
|
+ // gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), e);
|
|
|
|
|
+ // });
|
|
|
|
|
+ // req.end();
|
|
|
|
|
+ // }
|
|
|
|
|
+ //});
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
var commonsLength = 0;
|
|
var commonsLength = 0;
|
|
|
var jvmLenght = 0;
|
|
var jvmLenght = 0;
|