From 7a4b19f14b3a88475415782fa64794817121346a Mon Sep 17 00:00:00 2001 From: himetani_cafe Date: Mon, 25 Jan 2016 23:20:43 +0900 Subject: [PATCH] =?utf8?q?[DEBUG]=20dbOption=E3=81=AE=E8=A8=AD=E5=AE=9A=20?= =?utf8?q?=20On=20branch=20master=20=20Changes=20to=20be=20committed:=20?= =?utf8?q?=20=20=20=20modified:=20=20=20server/class/DB.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- server/class/DB.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/server/class/DB.js b/server/class/DB.js index 5b2feea..d37b7a9 100644 --- a/server/class/DB.js +++ b/server/class/DB.js @@ -13,11 +13,7 @@ function DB() { var sequelize; var test = 'hello'; - - var dbOption = { - dialect: 'sqlite' - }; - + /** * sync * @@ -28,15 +24,21 @@ function DB() { var force = process.env.NODE_ENV !== 'production'; Files.sync({force: force}) .then(function() { + return existDirectory(q); + }) + .catch(function() { var root = { fileId: '1f83f620-c1ed-11e5-9657-7942989daa00', // rootのuuidは固定値 name: '/', parentId: '', fileType: 0 }; + /* if(process.env.NODE_ENV === 'debug') { return Files.create(root); } + */ + return Files.create(root); }) .then(function() { var c = { @@ -234,7 +236,7 @@ function DB() { } if(directory === '/') { - resolve('1f83f620-c1ed-11e5-9657-7942989daa00'); + resolve('1f83f620-c1ed-11e5-9657-7942989daa00'); // rootのuuid } else { arrayDirectory = directory.split('/'); arrayDirectory.shift(); // root @@ -488,7 +490,7 @@ function DB() { var q3 = { fileId: uuid.v1(), name: 'two', - parentId: '1f83f620-c1ed-11e5-9657-7942989daa00', + parentId: '1f83f620-c1ed-11e5-9657-7942989daa00', //rootのuuid fileType: 0 }; return Files.create(q3); @@ -523,6 +525,10 @@ function DB() { */ var dbPath; + var dbOption = { + dialect: 'sqlite' + }; + if(process.env['NODE_ENV'] === 'production') { dbPath = __dirname + '/../../user-specific-files/db/db.workspace'; // if doesn't exist workspace.db, create. @@ -531,6 +537,7 @@ function DB() { } catch(e) { fs.writeFileSync(dbPath, ''); } + dbOption.storage = dbPath; } else if(process.env['NODE_ENV'] === 'debug') { dbPath = __dirname + '/../../user-specific-files/db/db.debug'; @@ -541,10 +548,10 @@ function DB() { } fs.writeFileSync(dbPath, ''); + dbOption.storage = dbPath; } - dbOption.storage = dbPath; sequelize = new Sequelize('','','', dbOption); -- 2.11.0