• R/O
  • HTTP
  • SSH
  • HTTPS

zephyr: Commit

This repository is for zephyr, which is implemented for a GUI of Eos.


Commit MetaInfo

Revision3bfb6cb5443dfbe3771dfbed6b0f371ed37328ec (tree)
Time2016-01-25 21:09:20
Authorhimetani_cafe <fumifumi@yasu...>
Commiterhimetani_cafe

Log Message

[BUG FIX] check function reject by calling with no parameter.

Please enter the commit message for your changes. Lines starting
with will be ignored, and an empty message aborts the commit.
On branch master
Changes to be committed:

modified: class/DB.js

Changes not staged for commit:

modified: ../package.json
modified: ../test/mocha/DB.test.js

Change Summary

Incremental Difference

--- a/server/class/DB.js
+++ b/server/class/DB.js
@@ -188,7 +188,6 @@ function DB() {
188188 */
189189 function notExistFile(fileName, parentDirectory) {
190190 return new Promise(function(resolve, reject) {
191- console.log(fileName, parentDirectory);
192191 existDirectory(parentDirectory)
193192 .catch(function(error) {
194193 reject(error);
@@ -220,7 +219,17 @@ function DB() {
220219 */
221220 function existDirectory(directory) {
222221 return new Promise(function(resolve, reject) {
222+ if(!directory) {
223+ reject(new Error('parameter "directory" is undefined'));
224+ }
225+
223226 var arrayDirectory;
227+ var root = directory.substr(0,1);
228+
229+ if(root !== '/') {
230+ reject(new Error('directory name should start "/" so that it is absolute path including root.'));
231+ }
232+
224233 if(directory === '/') {
225234 resolve('1f83f620-c1ed-11e5-9657-7942989daa00');
226235 } else {
@@ -260,7 +269,17 @@ function DB() {
260269 */
261270 function notExistDirectory(directory) {
262271 return new Promise(function(resolve, reject) {
272+ if(!directory) {
273+ resolve();
274+ }
275+
263276 var arrayDirectory;
277+ var root = directory.substr(0,1);
278+
279+ if(root !== '/') {
280+ resolve();
281+ }
282+
264283 if(directory === '/') {
265284 reject(new Error('"' + directory + '" directory exists.'));
266285 } else {
@@ -301,6 +320,9 @@ function DB() {
301320 */
302321 function createFile(fileName,parentDirectory) {
303322 return new Promise(function(resolve, reject) {
323+ if(!fileName) {
324+ reject(new Error('filename is required.'));
325+ }
304326 Promise.all([existDirectory(parentDirectory), notExistFile(fileName, parentDirectory) ])
305327 .catch(function(error) {
306328 reject(error);
@@ -357,6 +379,10 @@ function DB() {
357379 */
358380 function createDirectory(directory) {
359381 return new Promise(function(resolve, reject) {
382+ if(!directory) {
383+ reject(new Error('directory name should start "/" so that it is absolute path including root.'));
384+ }
385+
360386 var leaf = directory.split('/').pop();
361387 var parentDirectory = directory.replace('/'+leaf, '');
362388 if(!parentDirectory) {
Show on old repository browser