diff --git a/Dockerfile b/Dockerfile index 282c7cf..9e026ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ EXPOSE 3000 USER root RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash - -RUN apt-get install -y nodejs python-gdal p7zip-full && npm install -g nodemon && \ +RUN apt-get install -y nodejs python-gdal unzip p7zip-full && npm install -g nodemon && \ ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \ ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal diff --git a/README.md b/README.md index cbb07bf..197345b 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,11 @@ If you are already running [ODM](https://github.com/OpenDroneMap/ODM) on Ubuntu 1) Install Entwine: https://entwine.io/quickstart.html#installation -2) Install node.js, npm dependencies and 7zip: +2) Install node.js, npm dependencies, 7zip and unzip: ```bash sudo curl --silent --location https://deb.nodesource.com/setup_6.x | sudo bash - -sudo apt-get install -y nodejs python-gdal p7zip-full +sudo apt-get install -y nodejs python-gdal p7zip-full unzip git clone https://github.com/OpenDroneMap/NodeODM cd NodeODM npm install diff --git a/config.js b/config.js index c0eee74..b93798f 100644 --- a/config.js +++ b/config.js @@ -119,7 +119,8 @@ config.maxConcurrency = parseInt(argv.max_concurrency || fromConfigFile("maxConc config.maxRuntime = parseInt(argv.max_runtime || fromConfigFile("maxRuntime", -1)); // Detect 7z availability -const childProcess = spawnSync("7z", ['--help']); -config.has7z = childProcess.status === 0; +config.has7z = spawnSync("7z", ['--help']).status === 0; +config.hasUnzip = spawnSync("unzip", ['--help']).status === 0; + module.exports = config; diff --git a/index.js b/index.js index 9808739..ac0eaf2 100644 --- a/index.js +++ b/index.js @@ -901,9 +901,9 @@ if (config.test) { if (config.testDropUploads) logger.info("Uploads will drop at random"); } -if (!config.has7z){ - logger.warn("The 7z program is not installed, falling back to legacy (zipping will be slower)"); -} +if (!config.hasUnzip) logger.warn("The unzip program is not installed, (certain unzip operations might be slower)"); +if (!config.has7z) logger.warn("The 7z program is not installed, falling back to legacy (zipping will be slower)"); + let commands = [ cb => odmInfo.initialize(cb), diff --git a/libs/processRunner.js b/libs/processRunner.js index 2669316..7c356f2 100644 --- a/libs/processRunner.js +++ b/libs/processRunner.js @@ -107,5 +107,13 @@ module.exports = { }, ["destination", "file"], null, + false), + + unzip: makeRunner("unzip", function(options){ + const opts = options.noDirectories ? ["-j"] : []; + return opts.concat(["-qq", "-o", options.file, "-d", options.destination]); + }, + ["destination", "file"], + null, false) }; diff --git a/libs/ziputils.js b/libs/ziputils.js index f7cb620..34ab15c 100644 --- a/libs/ziputils.js +++ b/libs/ziputils.js @@ -5,7 +5,19 @@ const fs = require('fs'); module.exports = { unzip: function(file, outputDir, cb, noDirectories = false){ - if (config.has7z){ + if (config.hasUnzip){ + processRunner.unzip({ + file: file, + destination: outputDir, + noDirectories + }, (err, code, _) => { + if (err) cb(err); + else{ + if (code === 0) cb(); + else cb(new Error(`Could not extract .zip file, unzip exited with code ${code}`)); + } + }); + }else if (config.has7z){ processRunner.sevenUnzip({ file: file, destination: outputDir,