<commit_before>logger = require("logger-sharelatex")
fs = require("fs")
LocalFileWriter = require("./LocalFileWriter")

filterName = (key) ->
  return key.replace /\//, "_"
  

module.exports =
  sendFile: ( location, target, source, callback = (err)->) ->
    filteredTarget = filterName target
    logger.log location:location, target:filteredTarget, source:source, "sending file"
    fs.rename source, "#{location}/#{filteredTarget}", (err) ->
      if err!=null
        logger.err err:err, location:location, target:filteredTarget, source:source, "Error on put of file"
      callback err

  sendStream: ( location, target, sourceStream, callback = (err)->) ->
    logger.log location:location, target:target, "sending file stream"
    sourceStream.on "error", (err)-><commit_msg>Replace all instances of / in file paths in FSPersistorManager<commit_after>logger = require("logger-sharelatex")
fs = require("fs")
LocalFileWriter = require("./LocalFileWriter")

filterName = (key) ->
  return key.replace /\//g, "_"
  

module.exports =
  sendFile: ( location, target, source, callback = (err)->) ->
    filteredTarget = filterName target
    logger.log location:location, target:filteredTarget, source:source, "sending file"
    fs.rename source, "#{location}/#{filteredTarget}", (err) ->
      if err!=null
        logger.err err:err, location:location, target:filteredTarget, source:source, "Error on put of file"
      callback err

  sendStream: ( location, target, sourceStream, callback = (err)->) ->
    logger.log location:location, target:target, "sending file stream"
    sourceStream.on "error", (err)->
{'fraction_non_alphanumeric': 0.14400494437577255, 'fraction_numerical': 0.0, 'mean_word_length': 4.273615635179153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2764764', 'n_tokens_mistral': 474, 'n_tokens_neox': 466, 'n_words': 126}