diff options
author | John McLear <john@mclear.co.uk> | 2016-06-22 21:50:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-22 21:50:34 +0100 |
commit | 65dcb783d187683376d4751da8058651ce9c9411 (patch) | |
tree | 42dd8814f951e3f7aff9a5eebe9470a7103d57fd | |
parent | a18d40df6bccda35595adae63791a03590e417e7 (diff) | |
parent | 6b9711cb70c45c67224f4a12b371559883c78f19 (diff) | |
download | etherpad-lite-65dcb783d187683376d4751da8058651ce9c9411.zip |
Merge pull request #3008 from Gared/directory_check
Fixed path check
-rw-r--r-- | src/node/hooks/i18n.js | 2 | ||||
-rw-r--r-- | src/node/utils/caching_middleware.js | 3 | ||||
-rw-r--r-- | src/node/utils/path_exists.js | 15 |
3 files changed, 17 insertions, 3 deletions
diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index d0be2d6f..1b5b354d 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -5,7 +5,7 @@ var languages = require('languages4translatewiki') , npm = require('npm') , plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins.js').plugins , semver = require('semver') - , existsSync = fs.statSync || fs.existsSync || path.existsSync + , existsSync = require('../utils/path_exists') ; diff --git a/src/node/utils/caching_middleware.js b/src/node/utils/caching_middleware.js index 91b8143b..65fe5d2f 100644 --- a/src/node/utils/caching_middleware.js +++ b/src/node/utils/caching_middleware.js @@ -21,8 +21,7 @@ var path = require('path'); var zlib = require('zlib'); var settings = require('./Settings'); var semver = require('semver'); - -var existsSync = fs.statSync || fs.existsSync || path.existsSync; +var existsSync = require('./path_exists'); var CACHE_DIR = path.normalize(path.join(settings.root, 'var/')); CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined; diff --git a/src/node/utils/path_exists.js b/src/node/utils/path_exists.js new file mode 100644 index 00000000..c2d43f6c --- /dev/null +++ b/src/node/utils/path_exists.js @@ -0,0 +1,15 @@ +var fs = require('fs'); + +var check = function(path) { + var existsSync = fs.statSync || fs.existsSync || path.existsSync; + + var result; + try { + result = existsSync(path); + } catch (e) { + result = false; + } + return result; +} + +module.exports = check; |