         createCache: (convertedFilename, conversionParams, callback) =>
                 filepath = @_getCacheName conversionParams
                 input = fs.createReadStream convertedFilename
+                input.on "error", (err) =>
+                        console.log "Read stream error: #{err}"
                 output = fs.createWriteStream filepath
                 input.pipe output
                 input.on "end", =>

                @converters =
                        mp3: new Mp3Converter()
                        ogg: new VorbisConverter()

        _conversionDone: (err, cacheInstance, tempname, response) =>
                if err
                        fs.exists tempname, (exists) =>
                                if exists
                                        fs.unlink tempname
                                response.send "Failed to convert.", 500
                        return
                fs.stat tempname, (statErr, stats) =>
                        if statErr
                                response.send "Failed to read resulting file name.", 500
                                return
                        stream = fs.createReadStream tempname
                        stream.on "end", =>
                                fs.unlink tempname
                        cacheInstance.createCache tempname, (err, location) ->
                                response.set "location", location
                                response.send "Go to #{location}", 302

        convert: (type, filename, response) =>
                if type not of @converters

                                response.set "location", location
                                response.send "Go to #{location}", 302
                                return

                        fs.stat filename, (statErr, stats) =>
                                if statErr
                                        response.send "Failed to read original file name.", 500
                                        return

                                cacheKey = cacheInstance.getKey()
                                if cacheKey of @_ongoingConversions
                                        @_ongoingConversions[cacheKey].push response
                                        return
                                else
                                        @_ongoingConversions[cacheKey] = [response]

                                tempname = temp.path {suffix: ".#{suffix}"}
                                converter.convert filename, @bitrate, tempname, (err) =>
                                        @_conversionDone err, cacheInstance, tempname


exports.FileConverterView = class FileConverterView
