Skip to content

Commit d24b32d

Browse files
committed
Minor code enhancements
1 parent 6fb7f4e commit d24b32d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

files.coffee

+10-11
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,8 @@ class FilesCollection
803803
opts.path = "#{@storagePath}/#{FSName}#{extensionWithDot}"
804804

805805
request.get(url).on('error', (error)-> bound ->
806-
throw new Meteor.Error 500, "Error on [load(#{url})]:" + JSON.stringify error
806+
callback and callback error
807+
console.error "[FilesCollection] [load] [request.get(#{url})]:", error if self.debug
807808
).on('response', (response) -> bound ->
808809

809810
console.info "[FilesCollection] [load] Received: #{url}" if self.debug
@@ -821,7 +822,7 @@ class FilesCollection
821822
self.collection.insert _.clone(result), (error) ->
822823
if error
823824
callback and callback error
824-
console.warn "[FilesCollection] [load] [insert] Error: #{fileName} -> #{self.collectionName}", error if self.debug
825+
console.error "[FilesCollection] [load] [insert] Error: #{fileName} -> #{self.collectionName}", error if self.debug
825826
else
826827
callback and callback null, result
827828
console.info "[FilesCollection] [load] [insert] #{fileName} -> #{self.collectionName}" if self.debug
@@ -1384,31 +1385,29 @@ class FilesCollection
13841385
@memberOf FilesCollection
13851386
@name remove
13861387
@param {String|Object} search - `_id` of the file or `Object` like, {prop:'val'}
1387-
@param {Function} cb - Callback with one `error` argument
1388+
@param {Function} callback - Callback with one `error` argument
13881389
@summary Remove file(s) on cursor or find and remove file(s) if search is set
13891390
@returns {FilesCollection} Instance
13901391
###
1391-
remove: (search, cb) ->
1392+
remove: (search, callback) ->
13921393
console.info "[FilesCollection] [remove(#{JSON.stringify(search)})]" if @debug
13931394
check search, Match.Optional Match.OneOf Object, String
1394-
check cb, Match.Optional Function
1395+
check callback, Match.Optional Function
13951396

13961397
@srch search
13971398
if Meteor.isClient
13981399
if @allowClientCode
1399-
Meteor.call @methodNames.MeteorFileUnlink, search, (if cb then cb else NOOP)
1400+
Meteor.call @methodNames.MeteorFileUnlink, search, (callback or NOOP)
14001401
else
1401-
if cb
1402-
cb new Meteor.Error 401, '[FilesCollection] [remove] Run code from client is not allowed!'
1403-
else
1404-
throw new Meteor.Error 401, '[FilesCollection] [remove] Run code from client is not allowed!'
1402+
callback and callback new Meteor.Error 401, '[FilesCollection] [remove] Run code from client is not allowed!'
1403+
console.warn '[FilesCollection] [remove] Run code from client is not allowed!' if @debug
14051404

14061405
if Meteor.isServer
14071406
files = @collection.find @search
14081407
if files.count() > 0
14091408
self = @
14101409
files.forEach (file) -> self.unlink file
1411-
@collection.remove @search, cb
1410+
@collection.remove @search, (callback or NOOP)
14121411
return @
14131412

14141413
###

0 commit comments

Comments
 (0)