papercut
papercut copied to clipboard
Process returns unexpected results when run from async.parallel
I am iterating over a set of images and using async.parralel and the hash of image urls in the callback from process contains urls from many different calls to process:
Schema.process name, path, (err, images)->
console.log "processPhoto images: ", _.prettyPrint(images)
->
2013-11-14T18:03:27.503Z - debug: processPhoto images: {
"avatar-icon": "https://s3.amazonaws.com/mw-development/impact-avatar-icon.jpg",
"avatar-column": "https://s3.amazonaws.com/mw-development/impact-avatar-column.jpg",
"avatar-card": "https://s3.amazonaws.com/mw-development/team-avatar-card.jpg",
"large": "https://s3.amazonaws.com/mw-development/city-large.jpg"
}
In this example I would expect the urls to all contain 'impact' and not 'team' or 'city'
@jesseclark You're right. It appears an instance of an uploader saves its results in itself. A workaround for now, is to instantiate a new uploader every time you upload. i.e.
async.parallel, [
(done) ->
uploader = new Uploader()
uploader.process name, path, (err, images)->
console.log "processPhoto images: ", _.prettyPrint(images)
done()
, ...
]
I can work on a pull request to fix this if necessary.