From 63da3ba331aa3d9714151ba5f502e6e1851d75bb Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 14 Aug 2014 15:21:48 -0400 Subject: only clobber thumbnail if layout changed --- server/lib/api/projects.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'server/lib/api') diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js index fc54a5f..bd3cb81 100644 --- a/server/lib/api/projects.js +++ b/server/lib/api/projects.js @@ -72,15 +72,20 @@ var projects = { data.slug = util.slugify(data.name) data.description = util.sanitize(data.description) - upload.put("projects", req.files.thumbnail, { - unacceptable: function(err){ - res.json({ error: { errors: { thumbnail: { message: "Problem saving thumbnail: " + err } } } }) - }, - success: function(url){ - data.photo = url - done() - } - }) + if (req.files.thumbnail) { + upload.put("projects", req.files.thumbnail, { + unacceptable: function(err){ + res.json({ error: { errors: { thumbnail: { message: "Problem saving thumbnail: " + err } } } }) + }, + success: function(url){ + data.photo = url + done() + } + }) + } + else { + done() + } function done() { Project.findOne({ _id: _id }, function(err, doc){ -- cgit v1.2.3-70-g09d2