diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index de987c0c..1dd85c86 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -759,12 +759,14 @@ var FileSystemLoaderActions = actions.Actions({ // - remove non-existing previews from index // - replace non-existing originals with the largest preview (in index) // ...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... - checkIndex: ['File/', + checkIndex: ['File/Check index consistency', core.doc` `, function(logger){ + var that = this logger = logger || this.logger logger = logger && logger.push('Checking index') @@ -773,12 +775,15 @@ var FileSystemLoaderActions = actions.Actions({ throw new Error('.fixIndex(): combined indexes not supported.') } + logger + && this.images + .forEach(function(gid){ + logger.emit('queued', gid)}) + + + /* // XXX this version of the code blocks the ui until it's + // done... return this.images - .run(function(){ - logger - && this - .forEach(function(gid){ - logger.emit('queued', gid)}) }) .map(function(gid, image){ var updated = false @@ -797,7 +802,58 @@ var FileSystemLoaderActions = actions.Actions({ 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) }) }) + //*/ + }], }) diff --git a/ui (gen4)/features/ui-progress.js b/ui (gen4)/features/ui-progress.js index d1b97ae1..5ab4dcd0 100755 --- a/ui (gen4)/features/ui-progress.js +++ b/ui (gen4)/features/ui-progress.js @@ -137,6 +137,9 @@ var ProgressActions = actions.Actions({ }, 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?) }], }) diff --git a/ui (gen4)/imagegrid/images.js b/ui (gen4)/imagegrid/images.js index 8858cdcf..bb64632b 100755 --- a/ui (gen4)/imagegrid/images.js +++ b/ui (gen4)/imagegrid/images.js @@ -421,6 +421,7 @@ module.ImagesPrototype = { }, reduce: function(func, initial){ var res = initial + var i = 0 for(var key in this){ // reject non images... // XXX make this cleaner... diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index f9b7d32d..30d9e109 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -119,25 +119,27 @@ $(function(){ var msg = this.message var log = this.log = this.log || [] + var i = v instanceof Array ? v.length : 1 + // report progress... // XXX HACK -- need meaningful status... if(e == 'queued' || e == 'found'){ - ig.showProgress(msg || ['Progress', e], '+0', '+1') + ig.showProgress(msg || ['Progress', e], '+0', '+'+i) } else if(e == 'loaded' || e == 'done' || e == 'written' || e == 'index'){ - ig.showProgress(msg || ['Progress', e], '+1') + ig.showProgress(msg || ['Progress', e], '+'+i) } else if(e == 'skipping' || e == 'skipped'){ // XXX if everything is skipped the indicator does not // get hidden... //ig.showProgress(msg || ['Progress', e], '+0', '-1') - ig.showProgress(msg || ['Progress', e], '+1') + ig.showProgress(msg || ['Progress', e], '+'+i) // XXX STUB... } else if(e == 'error' ){ - ig.showProgress(['Error'].concat(msg), '+0', '+1') + ig.showProgress(['Error'].concat(msg), '+0', '+'+i) console.log(msg ? ' '+ msg.join(': ') + ':' : '', ...arguments)