mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactored listing of indexes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
515863f94e
commit
d960b02466
@ -106,6 +106,24 @@ function(base, index_dir){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: this is similar to listIndexes(..) but will return a promise and
|
||||||
|
// skip all non-loadable nested indexes...
|
||||||
|
var getIndexes =
|
||||||
|
module.getIndexes =
|
||||||
|
function(base, index_dir, logger){
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
listIndexes(base, index_dir)
|
||||||
|
.on('error', function(err){
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
.on('end', function(paths){
|
||||||
|
// skip nested indexes...
|
||||||
|
resolve(skipNested(paths, index_dir, logger))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var listPreviews =
|
var listPreviews =
|
||||||
module.listPreviews =
|
module.listPreviews =
|
||||||
function(base){
|
function(base){
|
||||||
@ -336,17 +354,12 @@ function(path, index_dir, logger){
|
|||||||
} else {
|
} else {
|
||||||
var res = {}
|
var res = {}
|
||||||
|
|
||||||
// XXX handle 'error' event...
|
getIndexes(path, index_dir, logger)
|
||||||
listIndexes(path, index_dir)
|
.catch(function(err){
|
||||||
// XXX handle errors...
|
|
||||||
.on('error', function(err){
|
|
||||||
logger && logger.emit('error', err)
|
logger && logger.emit('error', err)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
.on('end', function(paths){
|
.then(function(paths){
|
||||||
// skip nested indexes...
|
|
||||||
paths = skipNested(paths, index_dir, logger)
|
|
||||||
|
|
||||||
// start loading...
|
// start loading...
|
||||||
Promise.all(paths.map(function(p){
|
Promise.all(paths.map(function(p){
|
||||||
var path = pathlib.normalize(p +'/'+ index_dir)
|
var path = pathlib.normalize(p +'/'+ index_dir)
|
||||||
@ -563,16 +576,12 @@ function(path, index_dir, from_date, logger){
|
|||||||
} else {
|
} else {
|
||||||
var res = {}
|
var res = {}
|
||||||
|
|
||||||
listIndexes(path, index_dir)
|
getIndexes(path, index_dir, logger)
|
||||||
// XXX handle errors...
|
.catch(function(err){
|
||||||
.on('error', function(err){
|
|
||||||
logger && logger.emit('error', err)
|
logger && logger.emit('error', err)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
.on('end', function(paths){
|
.then(function(paths){
|
||||||
// skip nested indexes...
|
|
||||||
paths = skipNested(paths, index_dir, logger)
|
|
||||||
|
|
||||||
// start loading...
|
// start loading...
|
||||||
Promise.all(paths.map(function(p){
|
Promise.all(paths.map(function(p){
|
||||||
var path = pathlib.normalize(p +'/'+ index_dir)
|
var path = pathlib.normalize(p +'/'+ index_dir)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user