larvitfiles
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -44,4 +44,18 @@ 'use strict'; | ||
// Check so slug is not an empty string | ||
tasks.push(function(cb) { | ||
if (newFileData.slug === '') { | ||
data.global.errors.push('Slug can not be empty'); | ||
} | ||
cb(); | ||
}); | ||
// Check so slug is not taken | ||
tasks.push(function(cb) { | ||
if (data.global.errors.length !== 0) { | ||
cb(); | ||
return; | ||
} | ||
if ((file !== undefined && file.slug !== newFileData.slug) || file === undefined) { | ||
@@ -52,3 +66,3 @@ lFiles.getFileUuidBySlug(newFileData.slug, function(err, result) { | ||
if ((result !== false && file !== undefined && file.uuid !== result) || (file === undefined && result !== false)) { | ||
data.global.errors = ['Slug already taken']; | ||
data.global.errors.push('Slug already taken'); | ||
} | ||
@@ -79,2 +93,7 @@ | ||
tasks.push(function(cb) { | ||
if (data.global.errors.length !== 0) { | ||
cb(); | ||
return; | ||
} | ||
if (file === undefined) { | ||
@@ -81,0 +100,0 @@ file = new lFiles.File(newFileData, cb); |
@@ -33,3 +33,3 @@ 'use strict'; | ||
if (options.slug) { | ||
if (options.slug !== undefined && options.slug !== '') { | ||
tasks.push(function(cb) { | ||
@@ -36,0 +36,0 @@ db.query('SELECT uuid, slug FROM larvitfiles_files WHERE slug = ?', [options.slug], function(err, rows) { |
{ | ||
"name": "larvitfiles", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Storage of files with an API and database to use in web environments", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
36378
880