From b847e962aae7035a09a0cb9d6a2d7d0eedb3a10b Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 31 Jan 2018 21:31:45 +0000 Subject: [PATCH] Handle project first-run without existing flow file --- red/runtime/storage/localfilesystem/projects/Project.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/red/runtime/storage/localfilesystem/projects/Project.js b/red/runtime/storage/localfilesystem/projects/Project.js index d5cc2cd04..f3def6d48 100644 --- a/red/runtime/storage/localfilesystem/projects/Project.js +++ b/red/runtime/storage/localfilesystem/projects/Project.js @@ -781,9 +781,14 @@ function createDefaultProject(user, project) { files.push(baseCredentialFileName); flowFilePath = fspath.join(projectPath,baseFlowFileName); credsFilePath = fspath.join(projectPath,baseCredentialFileName); - log.trace("Migrating "+project.files.oldFlow+" to "+flowFilePath); + if (fs.existsSync(project.files.oldFlow)) { + log.trace("Migrating "+project.files.oldFlow+" to "+flowFilePath); + promises.push(fs.copy(project.files.oldFlow,flowFilePath)); + } else { + log.trace(project.files.oldFlow+" does not exist - creating blank file"); + promises.push(util.writeFile(flowFilePath,"[]")); + } log.trace("Migrating "+project.files.oldCredentials+" to "+credsFilePath); - promises.push(fs.copy(project.files.oldFlow,flowFilePath)); runtime.nodes.setCredentialSecret(project.credentialSecret); promises.push(runtime.nodes.exportCredentials().then(function(creds) { var credentialData;