From 69420f1710949c8ce4f2bea6b4fc66b91bb9d5f7 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 24 Jan 2014 19:38:29 +0400 Subject: [PATCH] started testing the use of spawn instead of exec... Signed-off-by: Alex A. Naanou --- ui/compatibility.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/ui/compatibility.js b/ui/compatibility.js index 070f74a6..5b7efc6a 100755 --- a/ui/compatibility.js +++ b/ui/compatibility.js @@ -118,6 +118,7 @@ if(window.CEF_dumpJSON != null){ }) } + USE_EXEC = false // XXX this uses vips... window.getVipsField = function(field, source){ if(source in IMAGES){ @@ -125,12 +126,30 @@ if(window.CEF_dumpJSON != null){ var source = normalizePath(img.path) } var getter = $.Deferred() - var cmd = 'vips im_header_string "$FIELD" "$IN"' - .replace(/\$IN/g, osPath(source)) - .replace(/\$FIELD/g, field) - proc.exec(cmd, function(error, stdout, stderr){ - getter.resolve(stdout.trim()) - }) + + // exec... + if(USE_EXEC){ + var cmd = 'vips im_header_string "$FIELD" "$IN"' + .replace(/\$IN/g, osPath(source)) + .replace(/\$FIELD/g, field) + proc.exec(cmd, function(error, stdout, stderr){ + getter.resolve(stdout.trim()) + }) + + // spawn... + // NOTE: this should have significantly less overhead than running a shell... + } else { + var p = proc.spawn('vips', ['im_header_string', field, osPath(source)]) + p.stdout.on('data', function(data){ + getter.resolve(data.toString().trim()) + }) + /* + p.on('close', function(code){ + getter.resolve(code) + }) + */ + } + return getter }