sligtly de-dumbefied file.loadIndex(..) which should significintly speed up some paths loading (still needs work)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-02-11 04:40:22 +03:00
parent 6d2da52b4e
commit c13f0b3054
2 changed files with 22 additions and 2 deletions

View File

@ -365,6 +365,7 @@ var FileSystemLoaderActions = actions.Actions({
loadIndex: ['- File/Load index',
function(path, from_date, logger){
var that = this
var index_dir = util.normalizePath(this.config['index-dir'])
// XXX get a logger...
logger = logger || this.logger
logger = logger && logger.push('Load')
@ -382,7 +383,7 @@ var FileSystemLoaderActions = actions.Actions({
// XXX make this load incrementally (i.e. and EventEmitter
// a-la glob)....
//file.loadIndex(path, this.config['index-dir'], logger)
return file.loadIndex(path, this.config['index-dir'], from_date, logger)
return file.loadIndex(path, index_dir, from_date, logger)
.then(function(res){
// XXX if res is empty load raw...

View File

@ -502,9 +502,11 @@ function(path, index_dir, from_date, logger){
var i = util.normalizePath(index_dir).split(/[\\\/]/g)
var p = util.normalizePath(path).split(/[\\\/]/g).slice(-i.length)
var explicit_index_dir = (i.filter(function(e, j){ return e == p[j] }).length == i.length)
// we've got an index...
// XXX do we need to check if if it's a dir???
if(i.filter(function(e, j){ return e == p[j] }).length == i.length){
if(explicit_index_dir){
logger && logger.emit('path', path)
@ -601,6 +603,23 @@ function(path, index_dir, from_date, logger){
} else {
var res = {}
// special case: root index...
if(fse.existsSync(path +'/'+ index_dir)){
var n = path +'/'+ index_dir
return loadIndex(n, index_dir, from_date, logger)
.then(function(obj){
// NOTE: considering that all the paths within
// the index are relative to the preview
// dir (the parent dir to the index root)
// we do not need to include the index
// itself in the base path...
res[path] = obj[n]
resolve(res)
})
}
// full search...
getIndexes(path, index_dir, logger)
.catch(function(err){
logger && logger.emit('error', err)