<commit_before>var config = require('./config.json')

var fs = require('fs')

function FileTransfert(req, res){
  if(config.nginx.active){
    this.transfertNginx(req, res)
  } else {
    this.transfertNode(req, res)
  }
}

FileTransfert.prototype.transfertNode = function(req, res){
  var filename = config.directory.path + req.query.f
  fs.stat(filename, function (err, stats) {
    if (stats) {
      res.setHeader('Content-disposition', 'attachment; filename="' + req.query.f.split('\/').pop() + '"')
      res.setHeader('Content-Length', stats.size)
      res.setHeader('Content-type', 'application/octet-stream')

      var fReadStream = fs.createReadStream(filename)
      fReadStream.pipe(res)
      fReadStream.on('end', function () {
        Log.print(req.user + ' finish download file: ' + req.query.f)
      })
      fReadStream.on('end', function () {
        Log.print(req.user + ' stop download file: ' + req.query.f)
      })
      fReadStream.on('error', function (err) {
        Log.print(req.user + ' error during download file: ' + req.query.f + '\n err: '+err)
      })
    } else {
      res.end("Le fichier n'existe pas")
    }
  })
}

FileTransfert.prototype.transfertNginx = function(req, res){
  res.redirect(config.nginx.domain+":"+config.nginx.port+"/"+config.nginx.path+"/"+req.query.f)
}
module.exports = FileTransfert<commit_msg>auto get host domain<commit_after>var config = require('./config.json')

var fs = require('fs')

function FileTransfert(req, res){
  if(config.nginx.active){
    this.transfertNginx(req, res)
  } else {
    this.transfertNode(req, res)
  }
}

FileTransfert.prototype.transfertNode = function(req, res){
  var filename = config.directory.path + req.query.f
  fs.stat(filename, function (err, stats) {
    if (stats) {
      res.setHeader('Content-disposition', 'attachment; filename="' + req.query.f.split('\/').pop() + '"')
      res.setHeader('Content-Length', stats.size)
      res.setHeader('Content-type', 'application/octet-stream')

      var fReadStream = fs.createReadStream(filename)
      fReadStream.pipe(res)
      fReadStream.on('end', function () {
        Log.print(req.user + ' finish download file: ' + req.query.f)
      })
      fReadStream.on('end', function () {
        Log.print(req.user + ' stop download file: ' + req.query.f)
      })
      fReadStream.on('error', function (err) {
        Log.print(req.user + ' error during download file: ' + req.query.f + '\n err: '+err)
      })
    } else {
      res.end("Le fichier n'existe pas")
    }
  })
}

FileTransfert.prototype.transfertNginx = function(req, res){
  res.redirect("http://"+req.headers['host']+":"+config.nginx.port+"/"+config.nginx.path+"/"+req.query.f)
}
module.exports = FileTransfert
{'fraction_non_alphanumeric': 0.17281695286810375, 'fraction_numerical': 0.0, 'mean_word_length': 3.2848200312989047, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2317721', 'n_tokens_mistral': 927, 'n_tokens_neox': 916, 'n_words': 156}