diff options
author | Simon Bartlett <simon@securitycompass.com> | 2015-05-20 16:40:00 -0400 |
---|---|---|
committer | Simon Bartlett <simon@securitycompass.com> | 2015-05-20 16:40:00 -0400 |
commit | 5ca7cf5f4fb1ff926bacf8fc63177a20e1bcc7f8 (patch) | |
tree | 3fc97a7f080de6e100c46cd5f894196d5bd4aa34 /app/core/files.js | |
parent | bd222d77222ecb62309ca31a18a2696a15322887 (diff) | |
parent | 5eeb87c0e2dc8864c52249386f216889a276d400 (diff) | |
download | lets-chat-5ca7cf5f4fb1ff926bacf8fc63177a20e1bcc7f8.zip lets-chat-5ca7cf5f4fb1ff926bacf8fc63177a20e1bcc7f8.tar.gz lets-chat-5ca7cf5f4fb1ff926bacf8fc63177a20e1bcc7f8.tar.bz2 |
Merge branch 'master' into develop
# Conflicts:
# app/controllers/rooms.js
# app/core/presence.js
# app/core/presence/user-collection.js
# app/models/room.js
# app/xmpp/msg-processors/roster-get.js
# app/xmpp/msg-processors/vcard-get.js
Diffstat (limited to 'app/core/files.js')
-rw-r--r-- | app/core/files.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/core/files.js b/app/core/files.js index a271785..7b5efa8 100644 --- a/app/core/files.js +++ b/app/core/files.js @@ -1,12 +1,12 @@ 'use strict'; -var fs = require('fs'), - _ = require('lodash'), +var _ = require('lodash'), mongoose = require('mongoose'), helpers = require('./helpers'), plugins = require('./../plugins'), - settings = require('./../config').files, - enabled = settings.enable; + settings = require('./../config').files; + +var enabled = settings.enable; function FileManager(options) { this.core = options.core; @@ -63,11 +63,16 @@ FileManager.prototype.create = function(options, cb) { size: options.file.size, room: options.room }).save(function(err, savedFile) { + if (err) { + return cb(err); + } + this.provider.save({file: options.file, doc: savedFile}, function(err) { if (err) { savedFile.remove(); return cb(err); } + // Temporary workaround for _id until populate can do aliasing User.findOne(options.owner, function(err, user) { if (err) { @@ -113,8 +118,7 @@ FileManager.prototype.list = function(options, cb) { maxTake: 5000 }); - var File = mongoose.model('File'), - User = mongoose.model('User'); + var File = mongoose.model('File'); var find = File.find({ room: options.room |