some refactoring + made browse-walk draw a dir in sync (fixed unstable ordering)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-09 18:30:16 +03:00
parent 08cb529fc3
commit bebfe3131e

View File

@ -91,6 +91,18 @@ function(path, make){
// XXX expose these as config... // XXX expose these as config...
var fullpath = false var fullpath = false
// sync version of stat...
var stat = function(path){
return new Promise(function(resolve, reject){
try {
resolve(fs.statSync(path))
} catch(err){
reject(err)
}
})
}
/*
var stat = function(path){ var stat = function(path){
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
fs.stat.call(fs, path, function(err, res){ fs.stat.call(fs, path, function(err, res){
@ -98,6 +110,7 @@ function(path, make){
}) })
}) })
} }
*/
// get the drive list on windows... // get the drive list on windows...
if(os.type() == 'Windows_NT' && path == '/'){ if(os.type() == 'Windows_NT' && path == '/'){
@ -164,7 +177,10 @@ function(path, make){
make(fullpath ? path + '../' : '../')) make(fullpath ? path + '../' : '../'))
} }
files.map(function(file){ // XXX split out the making stage after the stat stage to
// be able to sort suff correctly...
files
.map(function(file){
return stat(path +'/'+ file) return stat(path +'/'+ file)
.catch(function(err){ .catch(function(err){
make(fullpath make(fullpath