OSDN Git Service

[DEBUG] dbOptionの設定 v0.3.0p0018
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 25 Jan 2016 14:20:43 +0000 (23:20 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 25 Jan 2016 14:20:43 +0000 (23:20 +0900)
 On branch master
 Changes to be committed:
    modified:   server/class/DB.js

server/class/DB.js

index 5b2feea..d37b7a9 100644 (file)
@@ -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);