From d2a5e3c15e89b5407130bbfbd3cf364f1ed2d72d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 8 Dec 2020 20:07:49 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- Viewer/features/core.js | 7 ++-- Viewer/features/filesystem.js | 10 +++--- Viewer/features/sharp.js | 60 ++++++++++++++++------------------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 2772b3ea..c2352fd3 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2693,13 +2693,12 @@ function(title, func){ && ([items, ...args] = arg_handler.call(this, undefined, items, ...args)) // run... - ;(items instanceof Array ? + return Promise.all( + (items instanceof Array ? items : [items]) .map(function(item){ - return func.call(that, item, ...args) }) - // XXX should we return anything in sync mode??? - return Promise.resolve() + return func.call(that, item, ...args) })) // queue mode... } else { diff --git a/Viewer/features/filesystem.js b/Viewer/features/filesystem.js index 9892ffa9..37c924ba 100755 --- a/Viewer/features/filesystem.js +++ b/Viewer/features/filesystem.js @@ -57,13 +57,13 @@ var IndexFormatActions = actions.Actions({ // XXX should these be 'p' or 'px' (current)??? 'preview-sizes': [ - 75, - 200, + //75, + //200, 480, - 900, + //900, 1080, - 1440, - 2160, + //1440, + //2160, ], 'preview-sizes-priority': [ 75, diff --git a/Viewer/features/sharp.js b/Viewer/features/sharp.js index 9d7c97bc..8cdf1ce2 100755 --- a/Viewer/features/sharp.js +++ b/Viewer/features/sharp.js @@ -470,38 +470,34 @@ var SharpActions = actions.Actions({ || img.base_path || this.location.path - return sizes - .map(function(size, i){ - var name = path = path_tpl - .replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size)) - .replace(/\$GID|\$\{GID\}/g, gid) - .replace(/\$NAME|\$\{NAME\}/g, img.name) - // NOTE: we are 'sync' here for several reasons, mainly because - // this is a small list and in this way we can take - // advantage of OS file caching, and removing the queue - // overhead, though small makes this noticeably faster... - return that.makeResizedImage('sync', gid, size, base, { - name, - skipSmaller: true, - transform: false, - logger: logger_mode == 'gids' ? - false - : logger, - }) - // XXX handle errors -- rejected because image exists... - .then(function(res){ - // did not create a preview... - if(!res){ - return false } - - // update metadata... - if(!base_path){ - var preview = img.preview = img.preview || {} - preview[parseInt(size) + 'px'] = name - that.markChanged - && that.markChanged('images', [gid]) } - - return [gid, size, name] }) }) })], + return Promise.all( + sizes + .map(function(size, i){ + var name = path = path_tpl + .replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size)) + .replace(/\$GID|\$\{GID\}/g, gid) + .replace(/\$NAME|\$\{NAME\}/g, img.name) + // NOTE: we are 'sync' here for several reasons, mainly because + // this is a small list and in this way we can take + // advantage of OS file caching, and removing the queue + // overhead, though small makes this noticeably faster... + return that.makeResizedImage('sync', gid, size, base, { + name, + skipSmaller: true, + transform: false, + logger: logger_mode == 'gids' ? + false + : logger, + }) + // XXX handle errors -- rejected because image exists... + .then(function(res){ + // update metadata... + if(!base_path){ + var preview = img.preview = img.preview || {} + preview[parseInt(size) + 'px'] = name + that.markChanged + && that.markChanged('images', [gid]) } + return [gid, size, name] }) })) })], // XXX add support for offloading the processing to a thread/worker... // XXX revise logging and logger passing...