mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
.checkIndex() mostly done...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
530102521f
commit
45c54f931b
@ -759,12 +759,14 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
// - remove non-existing previews from index
|
// - remove non-existing previews from index
|
||||||
// - replace non-existing originals with the largest preview (in index)
|
// - replace non-existing originals with the largest preview (in index)
|
||||||
// ...do not touch the fs
|
// ...do not touch the fs
|
||||||
// XXX this does not give the logger to render...
|
// XXX this does not give the logger to render... can't seem to make this
|
||||||
|
// not block the browser render...
|
||||||
// XXX set changes...
|
// XXX set changes...
|
||||||
checkIndex: ['File/',
|
checkIndex: ['File/Check index consistency',
|
||||||
core.doc`
|
core.doc`
|
||||||
`,
|
`,
|
||||||
function(logger){
|
function(logger){
|
||||||
|
var that = this
|
||||||
logger = logger || this.logger
|
logger = logger || this.logger
|
||||||
logger = logger && logger.push('Checking index')
|
logger = logger && logger.push('Checking index')
|
||||||
|
|
||||||
@ -773,12 +775,15 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
throw new Error('.fixIndex(): combined indexes not supported.')
|
throw new Error('.fixIndex(): combined indexes not supported.')
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.images
|
|
||||||
.run(function(){
|
|
||||||
logger
|
logger
|
||||||
&& this
|
&& this.images
|
||||||
.forEach(function(gid){
|
.forEach(function(gid){
|
||||||
logger.emit('queued', gid)}) })
|
logger.emit('queued', gid)})
|
||||||
|
|
||||||
|
|
||||||
|
/* // XXX this version of the code blocks the ui until it's
|
||||||
|
// done...
|
||||||
|
return this.images
|
||||||
.map(function(gid, image){
|
.map(function(gid, image){
|
||||||
var updated = false
|
var updated = false
|
||||||
|
|
||||||
@ -797,7 +802,58 @@ var FileSystemLoaderActions = actions.Actions({
|
|||||||
|
|
||||||
return updated ? gid : []
|
return updated ? gid : []
|
||||||
})
|
})
|
||||||
.flat() }],
|
.flat()
|
||||||
|
/*/
|
||||||
|
var chunk_size = 50
|
||||||
|
return new Promise(function(resolve, reject){
|
||||||
|
var res = []
|
||||||
|
that.images
|
||||||
|
.reduce(function(res, e, gid){
|
||||||
|
var c = res.slice(-1)[0]
|
||||||
|
c.length < chunk_size ?
|
||||||
|
c.push([gid, e])
|
||||||
|
: res.push([[gid, e]])
|
||||||
|
return res
|
||||||
|
}, [[]])
|
||||||
|
.map(function(chunk, i, chunks){
|
||||||
|
setTimeout(function(){
|
||||||
|
res.push(chunk
|
||||||
|
// NOTE: all this complication with promises is
|
||||||
|
// needed to let the ui a chance to show
|
||||||
|
// progress...
|
||||||
|
// NOTE: if a better way is found this is the
|
||||||
|
// only part needed, just iterate over
|
||||||
|
// return this.images
|
||||||
|
// .map(function(gid, image){
|
||||||
|
// // place the func body here...
|
||||||
|
// ...
|
||||||
|
// })
|
||||||
|
.map(function(v){
|
||||||
|
var gid = v[0]
|
||||||
|
var image = v[1]
|
||||||
|
var updated = false
|
||||||
|
|
||||||
|
var previews = image.preview || {}
|
||||||
|
Object.entries(previews)
|
||||||
|
.forEach(function(p){
|
||||||
|
!fse.existsSync(image.base_path +'/'+ p[1])
|
||||||
|
&& (updated = true)
|
||||||
|
&& (delete previews[p[0]]) })
|
||||||
|
|
||||||
|
!fse.existsSync(image.base_path +'/'+ image.path)
|
||||||
|
&& (updated = true)
|
||||||
|
&& (delete image.path)
|
||||||
|
|
||||||
|
logger && logger.emit('done', gid)
|
||||||
|
|
||||||
|
return updated ? gid : []
|
||||||
|
}))
|
||||||
|
|
||||||
|
i >= chunks.length-1
|
||||||
|
&& resolve(res.flat(Infinity))
|
||||||
|
}, 0) }) })
|
||||||
|
//*/
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,9 @@ var ProgressActions = actions.Actions({
|
|||||||
}, this.config['progress-done-delay'] || 1000)))
|
}, this.config['progress-done-delay'] || 1000)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX force the browser to render...
|
||||||
|
//bar.hide(0).show(0)
|
||||||
|
|
||||||
// XXX what should we return??? (state, self, controller?)
|
// XXX what should we return??? (state, self, controller?)
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
|
|||||||
@ -421,6 +421,7 @@ module.ImagesPrototype = {
|
|||||||
},
|
},
|
||||||
reduce: function(func, initial){
|
reduce: function(func, initial){
|
||||||
var res = initial
|
var res = initial
|
||||||
|
var i = 0
|
||||||
for(var key in this){
|
for(var key in this){
|
||||||
// reject non images...
|
// reject non images...
|
||||||
// XXX make this cleaner...
|
// XXX make this cleaner...
|
||||||
|
|||||||
@ -119,25 +119,27 @@ $(function(){
|
|||||||
var msg = this.message
|
var msg = this.message
|
||||||
var log = this.log = this.log || []
|
var log = this.log = this.log || []
|
||||||
|
|
||||||
|
var i = v instanceof Array ? v.length : 1
|
||||||
|
|
||||||
// report progress...
|
// report progress...
|
||||||
// XXX HACK -- need meaningful status...
|
// XXX HACK -- need meaningful status...
|
||||||
if(e == 'queued'
|
if(e == 'queued'
|
||||||
|| e == 'found'){
|
|| e == 'found'){
|
||||||
ig.showProgress(msg || ['Progress', e], '+0', '+1')
|
ig.showProgress(msg || ['Progress', e], '+0', '+'+i)
|
||||||
|
|
||||||
} else if(e == 'loaded' || e == 'done' || e == 'written'
|
} else if(e == 'loaded' || e == 'done' || e == 'written'
|
||||||
|| e == 'index'){
|
|| e == 'index'){
|
||||||
ig.showProgress(msg || ['Progress', e], '+1')
|
ig.showProgress(msg || ['Progress', e], '+'+i)
|
||||||
|
|
||||||
} else if(e == 'skipping' || e == 'skipped'){
|
} else if(e == 'skipping' || e == 'skipped'){
|
||||||
// XXX if everything is skipped the indicator does not
|
// XXX if everything is skipped the indicator does not
|
||||||
// get hidden...
|
// get hidden...
|
||||||
//ig.showProgress(msg || ['Progress', e], '+0', '-1')
|
//ig.showProgress(msg || ['Progress', e], '+0', '-1')
|
||||||
ig.showProgress(msg || ['Progress', e], '+1')
|
ig.showProgress(msg || ['Progress', e], '+'+i)
|
||||||
|
|
||||||
// XXX STUB...
|
// XXX STUB...
|
||||||
} else if(e == 'error' ){
|
} else if(e == 'error' ){
|
||||||
ig.showProgress(['Error'].concat(msg), '+0', '+1')
|
ig.showProgress(['Error'].concat(msg), '+0', '+'+i)
|
||||||
console.log(msg ?
|
console.log(msg ?
|
||||||
' '+ msg.join(': ') + ':'
|
' '+ msg.join(': ') + ':'
|
||||||
: '', ...arguments)
|
: '', ...arguments)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user