<commit_before>/*jslint es5:true, indent:2, maxlen:80, node:true*/
'use strict';
// Node.JS standard modules

var crypto = require('crypto'),
  fs = require('fs');

// 3rd-party modules

var Q = require('q'),
  mmm = require('mmmagic'),
  magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);

// custom modules

// promise-bound anti-callbacks

var detectFile = Q.nbind(magic.detectFile, magic);

// this module

/**
 * represents an individual file in the CDN, with required actions
 * @constructor
 */
var File = function (options) {
  var self = this,
    dfrd = Q.defer(),
    promises = [];

  options = options || {};

  this.localPath = options.localPath || '';
  this.path = options.path || '';
  this.mime = options.mime || '';
  this.md5 = options.md5 || '';
  this.size = options.size || 0;
  this.headers = null; // only those missing from destination
  this.promise = dfrd.promise;

  if (options.headers) {
    this.headers = JSON.parse(JSON.stringify(options.headers));
  } else {
    this.headers = {};
  }

  if (this.localPath) {
    if (!this.size) {
      promises.push(this.detectSize());
    }
    if (!this.mime) {
      promises.push(this.detectMIME());
    }
    if (!this.md5) {
      promises.push(this.calculateMD5());
    }
  }

  Q.all(promises).then(function () {
    process.nextTick(function () {
      dfrd.resolve(self);
    });
  }).done();

  return this;
};

File.prototype.constructor = File;

File.prototype.clone = function () {
  return new this.constructor(this);
};

File.prototype.setMIME = function (mime) {
  var parts,
    ext;

  if (mime.indexOf('text/') === 0) {<commit_msg>fix `File.prototype.clone` so that it doesn't bust the call stack<commit_after>/*jslint es5:true, indent:2, maxlen:80, node:true*/
'use strict';
// Node.JS standard modules

var crypto = require('crypto'),
  fs = require('fs');

// 3rd-party modules

var Q = require('q'),
  mmm = require('mmmagic'),
  magic = new mmm.Magic(mmm.MAGIC_MIME_TYPE);

// custom modules

// promise-bound anti-callbacks

var detectFile = Q.nbind(magic.detectFile, magic);

// this module

/**
 * represents an individual file in the CDN, with required actions
 * @constructor
 */
var File = function (options) {
  var self = this,
    dfrd = Q.defer(),
    promises = [];

  options = options || {};

  this.localPath = options.localPath || '';
  this.path = options.path || '';
  this.mime = options.mime || '';
  this.md5 = options.md5 || '';
  this.size = options.size || 0;
  this.headers = null; // only those missing from destination
  this.promise = dfrd.promise;

  if (options.headers) {
    this.headers = JSON.parse(JSON.stringify(options.headers));
  } else {
    this.headers = {};
  }

  if (this.localPath) {
    if (!this.size) {
      promises.push(this.detectSize());
    }
    if (!this.mime) {
      promises.push(this.detectMIME());
    }
    if (!this.md5) {
      promises.push(this.calculateMD5());
    }
  }

  Q.all(promises).then(function () {
    process.nextTick(function () {
      dfrd.resolve(self);
    });
  }).done();

  return this;
};

File.prototype.constructor = File;

File.prototype.clone = function () {
  return new File(this);
};

File.prototype.setMIME = function (mime) {
  var parts,
    ext;

  if (mime.indexOf('text/') === 0) {
{'fraction_non_alphanumeric': 0.16992665036674817, 'fraction_numerical': 0.006723716381418093, 'mean_word_length': 3.0557620817843865, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3768813', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1108, 'n_words': 243}