     json = JSON.stringify o, null, indent
   catch e
     return if cb? then cb e else e
-  tmpFileName = "#{uuid.v4()}.tmp"
+  tmpFileName = "#{@_getFileName uuid.v4()}.tmp"
   if cb?
     fs.writeFile tmpFileName, json, 'utf8', (err) ->
       return cb err if err

    if @_memory then done()
    else
      if cb?
        saveObjectToFile @_cache, file, done
      else
        err = (o = saveObjectToFile @_cache, file) instanceof Error
        done err, o
  else
    done = (err) =>

      @_cache = @allSync()

  _getFileName: (id) ->
    if @_single then path.join @_dir, (path.basename @name) + ".json"
    else id2fileName id, @_dir

  save: (id, o, cb=->) -> save.call @, id, o, cb
