                     mkdirp path.join(remoteConfig.path, doc.path), () ->
                         # Find if binary is already downloaded
                         db.get doc.binary.file.id, (err, binaryDoc) ->
-                            if binaryDoc?
+                            if binaryDoc? and binaryDoc.path isnt name
                                 # And move it to the right path
+                                log.info "Moving #{binaryDoc.path} to #{name}"
                                 fs.rename binaryDoc.path, name, () ->
                                     binaryDoc.path = name
                                     db.put binaryDoc, (err, res) ->

                        path: binaryPath
                    db.put binaryDoc, doc.binary.file.id, doc.binary.file.rev, (err, res) ->
                        if err? and err.status is 409
                            log.info "Binary already downloaded: #{path.join doc.path, doc.name}"
                            callback()
                        else
                            # Fetch binary via CouchDB API

process = require 'process'
uuid = require 'node-uuid'
async = require 'async'
chokidar = require 'chokidar'
urlParser = require 'url'
log = require('printit')
    prefix: 'Data Proxy'

