From 9a8b404054e53217f0c1d2bf9acc87c52e557dda Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 23 Aug 2017 17:31:33 +0100 Subject: [PATCH] Split localfilesystem storage plugin into component parts --- red/api/util.js | 3 - red/runtime/storage/localfilesystem.js | 441 ------------------ red/runtime/storage/localfilesystem/index.js | 187 ++++++++ .../storage/localfilesystem/library.js | 183 ++++++++ .../storage/localfilesystem/sessions.js | 52 +++ .../storage/localfilesystem/settings.js | 52 +++ red/runtime/storage/localfilesystem/util.js | 98 ++++ red/runtime/storage/projects/index.js | 0 .../index_spec.js} | 291 +----------- .../storage/localfilesystem/library_spec.js | 205 ++++++++ .../storage/localfilesystem/sessions_spec.js | 79 ++++ .../storage/localfilesystem/settings_spec.js | 80 ++++ .../storage/localfilesystem/util_spec.js | 31 ++ 13 files changed, 969 insertions(+), 733 deletions(-) delete mode 100644 red/runtime/storage/localfilesystem.js create mode 100644 red/runtime/storage/localfilesystem/index.js create mode 100644 red/runtime/storage/localfilesystem/library.js create mode 100644 red/runtime/storage/localfilesystem/sessions.js create mode 100644 red/runtime/storage/localfilesystem/settings.js create mode 100644 red/runtime/storage/localfilesystem/util.js create mode 100644 red/runtime/storage/projects/index.js rename test/red/runtime/storage/{localfilesystem_spec.js => localfilesystem/index_spec.js} (60%) create mode 100644 test/red/runtime/storage/localfilesystem/library_spec.js create mode 100644 test/red/runtime/storage/localfilesystem/sessions_spec.js create mode 100644 test/red/runtime/storage/localfilesystem/settings_spec.js create mode 100644 test/red/runtime/storage/localfilesystem/util_spec.js diff --git a/red/api/util.js b/red/api/util.js index ac2144d8f..256bb1b92 100644 --- a/red/api/util.js +++ b/red/api/util.js @@ -34,14 +34,11 @@ module.exports = { }, determineLangFromHeaders: function(acceptedLanguages){ - console.log("GOT",acceptedLanguages) var lang = i18n.defaultLang; acceptedLanguages = acceptedLanguages || []; if (acceptedLanguages.length >= 1) { - console.log("WE HAVE SOMETHING"); lang = acceptedLanguages[0]; } - console.log("RETURNING",lang); return lang; } } diff --git a/red/runtime/storage/localfilesystem.js b/red/runtime/storage/localfilesystem.js deleted file mode 100644 index 52fc86cd1..000000000 --- a/red/runtime/storage/localfilesystem.js +++ /dev/null @@ -1,441 +0,0 @@ -/** - * Copyright JS Foundation and other contributors, http://js.foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - **/ - -var fs = require('fs-extra'); -var when = require('when'); -var nodeFn = require('when/node/function'); -var keys = require('when/keys'); -var fspath = require("path"); -var mkdirp = fs.mkdirs; - -var log = require("../log"); - -var promiseDir = nodeFn.lift(mkdirp); - -var initialFlowLoadComplete = false; -var settings; -var flowsFile; -var flowsFullPath; -var flowsFileBackup; -var credentialsFile; -var credentialsFileBackup; -var oldCredentialsFile; -var sessionsFile; -var libDir; -var libFlowsDir; -var globalSettingsFile; - -function getFileMeta(root,path) { - var fn = fspath.join(root,path); - var fd = fs.openSync(fn,"r"); - var size = fs.fstatSync(fd).size; - var meta = {}; - var read = 0; - var length = 10; - var remaining = ""; - var buffer = Buffer(length); - while(read < size) { - read+=fs.readSync(fd,buffer,0,length); - var data = remaining+buffer.toString(); - var parts = data.split("\n"); - remaining = parts.splice(-1); - for (var i=0;i